Vector data · Angular, React and OpenLayers
Vector tiles from OGC API - Tiles
Render Natural Earth lake polygons as Mapbox Vector Tiles from an OGC API - Tiles WebMercatorQuad service in OpenLayers using flat styles.

What this example shows
Zoomed out to continental scale (zoom 3) across Europe and western Asia over OpenStreetMap, major Eurasian lakes—including Ladoga, Onega, Vänern, the Aral Sea, Balkhash and western Lake Baikal—stream as binary Mapbox Vector Tiles discovered automatically from an OGC API - Tiles JSON endpoint and render in translucent blue.
When you need it
OGC API - Tiles brings vendor-neutral JSON discovery and standardized tile matrix sets (WebMercatorQuad, WorldCRS84Quad) to binary vector tiles.
Pointing OpenLayers at the OGC tileset URL discovers the matrix grid and MVT item template automatically without hardcoding {z}/{x}/{y}.pbf paths.
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-vector-tiles.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
FormatMVTComponent,
LayerTileComponent,
LayerVectorTileComponent,
MapComponent,
SourceOGCVectorTileComponent,
SourceOsmComponent,
ViewComponent,
} from 'cc-openlayers';
/**
* The large lakes of Natural Earth as vector tiles from an OGC API - Tiles service (the pygeoapi demonstration
* server), drawn in a flat style over OpenStreetMap.
*/
@Component({
selector: 'app-ogc-vector-tiles',
imports: [
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
FormatMVTComponent,
LayerTileComponent,
LayerVectorTileComponent,
MapComponent,
SourceOGCVectorTileComponent,
SourceOsmComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-view [zoom]="3">
<aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
</aol-view>
<aol-layer-tile><aol-source-osm /></aol-layer-tile>
<aol-layer-vectortile [style]="style">
<aol-source-ogcvectortile
url="https://demo.pygeoapi.io/master/collections/lakes/tiles/WebMercatorQuad"
attributions="Lakes: Natural Earth"
>
<aol-format-mvt />
</aol-source-ogcvectortile>
</aol-layer-vectortile>
</aol-map>
`,
})
export class OgcVectorTiles {
protected readonly style = {
'stroke-width': 1.5,
'stroke-color': '#1f4e8c',
'fill-color': 'rgba(31, 78, 140, 0.45)',
};
} 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.
ogc-vector-tiles.react.tsximport {
Coordinate,
DefaultControls,
DefaultInteractions,
Map,
OGCVectorTileSource,
OSMSource,
TileLayer,
useMVTFormat,
VectorTileLayer,
View,
} from 'cc-openlayers/react';
const style = {
'stroke-width': 1.5,
'stroke-color': '#1f4e8c',
'fill-color': 'rgba(31, 78, 140, 0.45)',
};
/**
* The large lakes of Natural Earth as vector tiles from an OGC API - Tiles service (the pygeoapi demonstration
* server), drawn in a flat style over OpenStreetMap.
*/
export function OgcVectorTiles() {
const format = useMVTFormat();
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View zoom={3}>
<Coordinate x={19.9368} y={50.0614} srid="EPSG:4326" />
</View>
<TileLayer>
<OSMSource />
</TileLayer>
<VectorTileLayer style={style}>
<OGCVectorTileSource
url="https://demo.pygeoapi.io/master/collections/lakes/tiles/WebMercatorQuad"
attributions="Lakes: Natural Earth"
format={format}
/>
</VectorTileLayer>
</Map>
);
}How the React version works
Natural Earth's large lakes as vector tiles from an OGC API – Tiles service, in a flat style over OpenStreetMap.
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-ogcvectortile> with <aol-format-mvt> | <OGCVectorTileSource format> with a format from useMVTFormat |
<aol-layer-vectortile [style]> | <VectorTileLayer style> |
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-ogcvectortile fetches the JSON tileset metadata at url, resolves its linked WebMercatorQuad matrix set definition, and selects the tile URL template matching the MIME type supported by its child aol-format-mvt decoder.
A concise flat style paints each polygon with fill-color and stroke-color.
How it works
aol-source-ogcvectortilereads the OGC JSON tileset aturland configures theWebMercatorQuadtile pyramid automatically.aol-format-mvtdecodes incoming binary payloads as Mapbox Vector Tiles.- Flat style properties
fill-colorandstroke-colorrender translucent blue lake interiors with dark-blue shorelines. - Opening at zoom 3 frames major continental lakes across Europe and western Asia appropriate to the dataset’s global scale.
Pitfalls
- This demonstration collection serves 1:110M Natural Earth global overview polygons—zooming closely into individual shorelines reveals coarse generalised vertices inherent to the source dataset rather than a client rendering issue.
- OpenLayers does not reproject vector tiles on the fly: ensure the OGC tile matrix set CRS (here
WebMercatorQuad/ EPSG:3857) matches your map view projection.
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.