Tile and image services · Angular, React and OpenLayers

Map tiles from OGC API - Tiles

Load EuroGeographics raster tiles from an OGC API - Tiles JSON service in OpenLayers with aol-source-ogcmaptile and explicit CRS projection.

Kraków at zoom 11 in EuroGeographics' EuroRegionalMap, with its roads, the A4 motorway, the Vistula and Balice airport.
A screenshot of the example. EuroRegionalMap © EuroGeographics, served by CubeWerx's OGC API demonstration server.

What this example shows

Centred on Kraków at zoom 11—framing the A4 motorway bypass, the Vistula river and Balice airport—EuroGeographics’ cartographic EuroRegionalMap streams directly from a modern JSON-based OGC API - Tiles server.

When you need it

OGC API - Tiles is the modern REST/JSON successor to XML-heavy WMTS, adopted across next-generation European INSPIRE nodes, pygeoapi, CubeWerx and LDProxy deployments.

Instead of parsing verbose XML capability trees or handcrafting matrix grids, pointing OpenLayers at the JSON tileset endpoint discovers the tile matrix set and item URL template automatically.

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.

ogc-map-tiles.ts
import { ChangeDetectionStrategy, Component } from '@angular/core';
import {
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  LayerTileComponent,
  MapComponent,
  SourceOGCMapTileComponent,
  ViewComponent,
} from 'cc-openlayers';

/** EuroGeographics' EuroRegionalMap on CubeWerx's OGC API demonstration server. */
const EURO_REGIONAL_MAP = 'https://test.cubewerx.com/cubewerx/cubeserv/demo/ogcapi/EuroRegionalMap';

/** EuroGeographics' EuroRegionalMap around Kraków as map tiles from an OGC API - Tiles service. */
@Component({
  selector: 'app-ogc-map-tiles',
  imports: [
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerTileComponent,
    MapComponent,
    SourceOGCMapTileComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px">
      <aol-interaction-default />
      <aol-control-defaults />
      <aol-view [zoom]="11">
        <aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
      </aol-view>
      <aol-layer-tile>
        <!-- The service names its CRS with a URI OpenLayers cannot resolve: the projection is given instead. -->
        <aol-source-ogcmaptile [url]="url" projection="EPSG:3857" attributions="© EuroGeographics (EuroRegionalMap)" />
      </aol-layer-tile>
    </aol-map>
  `,
})
export class OgcMapTiles {
  /** The map tiles of the default style in the service's Web Mercator tile matrix set. */
  protected readonly url = `${EURO_REGIONAL_MAP}/collections/erm/styles/default/map/tiles/euro_3857`;
}

Architecture and OpenLayers mechanics

aol-source-ogcmaptile fetches the JSON tileset descriptor at [url] (here the default style’s Web Mercator tileset), follows its tile matrix set link, and extracts the raster tile URL template from its item link relation.

Supplying explicit projection="EPSG:3857" overrides a CRS identifier that OpenLayers cannot resolve on its own, so the tiles line up with the Web Mercator view.

How it works

  • aol-source-ogcmaptile reads both the JSON tileset metadata at [url] and its linked tile matrix set definition automatically.
  • The service’s own matrix set provides Web Mercator tiles aligned with standard view zoom levels.
  • projection="EPSG:3857" supplies a recognised CRS code where the server’s own CRS string does not resolve in OpenLayers.

Pitfalls

  • Omitting projection when an OGC API - Tiles server emits a non-standard CRS URI causes OpenLayers to log an Unsupported CRS error during metadata setup and leave the layer blank.
  • When a tileset omits per-level tileMatrixSetLimits, OpenLayers will request tiles anywhere in the world—add a geographic [extent] on the layer to avoid requesting empty tiles outside Europe.

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.