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.

The Vistula below Wawel in Kraków at zoom 15 in OpenStreetMap's Humanitarian style, with OpenSeaMap's marks for harbours and river signs along it.
A screenshot of the example. Map style © Humanitarian OpenStreetMap Team, hosted by OpenStreetMap France. Seamarks © OpenSeaMap. Map data © OpenStreetMap contributors.

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.ts
import { 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];
}

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}) to aol-source-osm switches 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 via ATTRIBUTION.
  • OSM sources default to non-collapsible attributions so both layer credits remain clearly visible.

Pitfalls

  • aol-source-osm requests 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.

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.