Projections · Angular, React and OpenLayers
OGC API vector tiles in WorldCRS84Quad
Serve static serverless Mapbox Vector Tiles in OGC WorldCRS84Quad geographic coordinates to an EPSG:4326 OpenLayers map using absolute URLs.

What this example shows
In a pure EPSG:4326 degree view at [zoom]="10" over background="#d1d1d1", Kraków and its surrounding county municipalities render in pale cream ('#f7f7e9') with crisp 0.6-pixel grey borders ('#8c8b8b') from a static folder of OGC WorldCRS84Quad .mvt files—requiring zero dynamic tile server.
When you need it
Static CDNs, offline Electron/Capacitor bundles and air-gapped intranets can host pre-generated OGC API - Tiles directory trees (WorldCRS84Quad.json + {z}/{y}/{x}.mvt files) as plain static assets.
Serving WorldCRS84Quad vector tiles directly into an EPSG:4326 view delivers crisp, unwarped geographic boundaries with zero backend compute.
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-geographic.shared.tsimport type { FlatStyle } from 'ol/style/flat.js';
/** The municipalities in pale yellow with grey borders. */
export const style: FlatStyle = {
'stroke-width': 0.6,
'stroke-color': '#8c8b8b',
'fill-color': '#f7f7e9',
};ogc-vector-tiles-geographic.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
FormatMVTComponent,
LayerVectorTileComponent,
MapComponent,
SourceOGCVectorTileComponent,
ViewComponent,
} from 'cc-openlayers';
import { style } from './ogc-vector-tiles-geographic.shared';
/**
* Kraków and the municipalities of its county as Mapbox vector tiles from an OGC API - Tiles tileset in the
* geographic WorldCRS84Quad tile matrix set, shown in a geographic view in a flat style. The tileset is static, in
* the gallery's assets (made by `tools/make-ogc-tilesets.mjs`).
*/
@Component({
selector: 'app-ogc-vector-tiles-geographic',
imports: [
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
FormatMVTComponent,
LayerVectorTileComponent,
MapComponent,
SourceOGCVectorTileComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-view projection="EPSG:4326" [zoom]="10">
<aol-coordinate [x]="19.94" [y]="50.1" srid="EPSG:4326" />
</aol-view>
<aol-layer-vectortile background="#d1d1d1" [style]="style">
<aol-source-ogcvectortile
[url]="url"
projection="EPSG:4326"
attributions="Boundaries: PRG, Główny Urząd Geodezji i Kartografii"
>
<aol-format-mvt />
</aol-source-ogcvectortile>
</aol-layer-vectortile>
</aol-map>
`,
})
export class OgcVectorTilesGeographic {
/** The tileset document, as an absolute URL: OpenLayers resolves the tile links against it. */
protected readonly url = new URL('assets/krakow/municipality-tiles/WorldCRS84Quad.json', document.baseURI).href;
protected readonly style = style;
} 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-geographic.react.tsximport {
Coordinate,
DefaultControls,
DefaultInteractions,
Map,
OGCVectorTileSource,
useMVTFormat,
VectorTileLayer,
View,
} from 'cc-openlayers/react';
import { style } from './ogc-vector-tiles-geographic.shared';
/** The tileset document, as an absolute URL: OpenLayers resolves the tile links against it. */
const TILESET = new URL('assets/krakow/municipality-tiles/WorldCRS84Quad.json', document.baseURI).href;
/**
* Kraków and the municipalities of its county as Mapbox vector tiles from an OGC API - Tiles tileset in the
* geographic WorldCRS84Quad tile matrix set, shown in a geographic view in a flat style. The tileset is static, in
* the gallery's assets (made by `tools/make-ogc-tilesets.mjs`).
*/
export function OgcVectorTilesGeographic() {
const format = useMVTFormat();
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View projection="EPSG:4326" zoom={10}>
<Coordinate x={19.94} y={50.1} srid="EPSG:4326" />
</View>
<VectorTileLayer background="#d1d1d1" style={style}>
<OGCVectorTileSource
url={TILESET}
projection="EPSG:4326"
attributions="Boundaries: PRG, Główny Urząd Geodezji i Kartografii"
format={format}
/>
</VectorTileLayer>
</Map>
);
}ogc-vector-tiles-geographic.shared.tsimport type { FlatStyle } from 'ol/style/flat.js';
/** The municipalities in pale yellow with grey borders. */
export const style: FlatStyle = {
'stroke-width': 0.6,
'stroke-color': '#8c8b8b',
'fill-color': '#f7f7e9',
};How the React version works
Kraków and the municipalities of its county as Mapbox vector tiles from a static OGC API – Tiles tileset in WorldCRS84Quad, in a view in degrees.
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. Both versions import the pale yellow style from the example's .shared.ts file, so the logic exists once.
From Angular to React
| Angular | React |
|---|---|
<aol-source-ogcvectortile> with <aol-format-mvt /> inside | <OGCVectorTileSource format={format}> with useMVTFormat() |
<aol-layer-vectortile background="#d1d1d1" [style]="style"> | <VectorTileLayer background="#d1d1d1" style={style}> |
<aol-view projection="EPSG:4326" [zoom]="10"> | <View projection="EPSG:4326" zoom={10}> |
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
Because the static JSON descriptor uses relative tile hrefs and OpenLayers resolves relative OGC item links via new URL(relativeHref, tilesetUrl), [url]="url" converts the asset path into a full absolute URL using new URL('assets/krakow/municipality-tiles/WorldCRS84Quad.json', document.baseURI).href.
aol-source-ogcvectortile pairs with <aol-format-mvt /> across matrix levels 4–10 (drawing matrix 9 at view [zoom]="10", 0.0014°/px).
How it works
aol-source-ogcvectortilereads the static tileset descriptor at[url]="url"and decodes tiles with<aol-format-mvt />.new URL('assets/krakow/municipality-tiles/WorldCRS84Quad.json', document.baseURI).hrefsupplies the scheme-and-host base URL OpenLayers needs to resolve relative tile links.- Matrix levels 4–10 cover the Kraków county area, with view
[zoom]="10"(0.0014°/px) renderingWorldCRS84Quadlevel 9. - Flat style rules fill municipalities in
'#f7f7e9'with0.6px'#8c8b8b'strokes overbackground="#d1d1d1".
Pitfalls
- Passing a bare relative path (a bare assets path) as
[url]fails when the JSON itself contains relative tile templates, because new URL(template, base) throws a TypeError whenbaselacks a protocol and host. - Remember the 1-level offset in
EPSG:4326: OpenLayers view zoom 0 is 1.40625°/px (1 tile wide) whereasWorldCRS84Quadlevel 0 is 0.703125°/px (2 tiles wide), so view zoom10requests matrix9.
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.