Tile and image services · Angular, React and OpenLayers
OpenStreetMap from another tile server
Point OpenLayers’ OSM source at custom regional tile servers and stack transparent OpenSeaMap river navigation marks over Kraków’s Vistula.

What this example shows
Zoomed to level 15 along the Vistula bend below Wawel Castle, the base map renders Humanitarian OpenStreetMap Team cartography served by OpenStreetMap France (tile-{a-c}), topped by a second transparent tile layer displaying OpenSeaMap inland-waterway signs, bridge clearances and harbour markers along the river.
When you need it
Regional geoportals, maritime/inland-navigation tools and enterprise intranets often replace the global tile.openstreetmap.org endpoint with national community mirrors, localized label renderings or internal OSM tile servers.
Stacking transparent thematic XYZ/OSM overlays—such as OpenSeaMap seamarks, hiking trails or railway signalling—on top of a custom base style composes rich domain maps from modular tile feeds.
The code
The example uses cc-openlayers, my Angular component library for OpenLayers: each aol-… element creates the OpenLayers object it names, updates it from its inputs and disposes of it with the component.
localized-openstreetmap.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import { ATTRIBUTION } from 'ol/source/OSM';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerTileComponent,
MapComponent,
SourceOsmComponent,
ViewComponent,
} from 'cc-openlayers';
/** OpenStreetMap from another tile server, the Humanitarian style, with OpenSeaMap's marks on the Vistula over it. */
@Component({
selector: 'app-localized-openstreetmap',
imports: [
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerTileComponent,
MapComponent,
SourceOsmComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-view [zoom]="15" [maxZoom]="18">
<aol-coordinate [x]="19.935" [y]="50.054" srid="EPSG:4326" />
</aol-view>
<aol-layer-tile>
<aol-source-osm
url="https://tile-{a-c}.openstreetmap.fr/hot/{z}/{x}/{y}.png"
[attributions]="hotAttributions"
/>
</aol-layer-tile>
<aol-layer-tile>
<aol-source-osm url="https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" [attributions]="seaAttributions" />
</aol-layer-tile>
</aol-map>
`,
})
export class LocalizedOpenstreetmap {
protected readonly hotAttributions = [
'Tiles style by <a href="https://www.hotosm.org/">Humanitarian OpenStreetMap Team</a> hosted by <a href="https://openstreetmap.fr/">OpenStreetMap France</a>',
ATTRIBUTION,
];
protected readonly seaAttributions = ['All maps © <a href="https://www.openseamap.org/">OpenSeaMap</a>', ATTRIBUTION];
} The React version uses the library's React adapter, cc-openlayers/react: each component creates the OpenLayers object it names when it mounts, updates it from its props and disposes of it when it unmounts.
localized-openstreetmap.react.tsximport { ATTRIBUTION } from 'ol/source/OSM.js';
import { Coordinate, DefaultControls, DefaultInteractions, Map, OSMSource, TileLayer, View } from 'cc-openlayers/react';
const HOT_ATTRIBUTIONS = [
'Tiles style by <a href="https://www.hotosm.org/">Humanitarian OpenStreetMap Team</a> hosted by <a href="https://openstreetmap.fr/">OpenStreetMap France</a>',
ATTRIBUTION,
];
const SEA_ATTRIBUTIONS = ['All maps © <a href="https://www.openseamap.org/">OpenSeaMap</a>', ATTRIBUTION];
/** OpenStreetMap from another tile server, the Humanitarian style, with OpenSeaMap's marks on the Vistula over it. */
export function LocalizedOpenstreetmap() {
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View zoom={15} maxZoom={18}>
<Coordinate x={19.935} y={50.054} srid="EPSG:4326" />
</View>
<TileLayer>
<OSMSource url="https://tile-{a-c}.openstreetmap.fr/hot/{z}/{x}/{y}.png" attributions={HOT_ATTRIBUTIONS} />
</TileLayer>
<TileLayer>
<OSMSource url="https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" attributions={SEA_ATTRIBUTIONS} />
</TileLayer>
</Map>
);
}How the React version works
The humanitarian OpenStreetMap style from another server with OpenSeaMap marks on the Vistula above it, each with its own attribution.
What both versions share
OpenLayers renders the map and handles the interactions; the cc-openlayers/core layer gives both adapters the same view binding (MapViewBinding) and the same conversion of coordinates from EPSG:4326 to the map's projection.
From Angular to React
| Angular | React |
|---|---|
<aol-source-osm [url] [attributions]> | <OSMSource url attributions> with module constants |
Who creates, updates and disposes
Map creates the ol/Map in useLayoutEffect and disposes of it on unmount; each layer, source and interaction component adds its object to the parent it gets from context and removes it in its effect's cleanup, as ngOnDestroy does in Angular.
Architecture and OpenLayers mechanics
aol-source-osm is not hardcoded to a single server: passing a custom url template (tile-{a-c}) redirects requests to OpenStreetMap France while retaining standard OSM defaults such as expanded attribution and CORS fetching.
A second aol-layer-tile + aol-source-osm mounts above the base layer pointing at OpenSeaMap’s transparent PNG seamark pyramid, and custom [attributions] on each source combine style-specific credits with OpenLayers’ ATTRIBUTION constant.
How it works
- Passing a custom
url(tile-{a-c}) toaol-source-osmswitches tile delivery to OpenStreetMap France’s Humanitarian style. - A second OSM layer stacks transparent OpenSeaMap waterway symbols directly above the river bend.
- Custom
[attributions]credit both Humanitarian OSM / OpenSeaMap and OpenStreetMap contributors viaATTRIBUTION. - OSM sources default to non-collapsible attributions so both layer credits remain clearly visible.
Pitfalls
aol-source-osmrequests tiles with anonymous CORS enabled by default: if a custom regional or intranet OSM server omits Access-Control-Allow-Origin headers, set crossOrigin to null or browsers will block tile loading.- Always verify the tile usage policy and rate limits of community mirrors such as OSM France or OpenSeaMap before production rollout.
Related examples
The same feature in the OpenLayers examples .
Background: state and lifecycle of maps in Angular with OpenLayers, which the components of cc-openlayers take care of.