Raster, GeoTIFF and WebGL · Angular, React and OpenLayers
Municipality vector tiles drawn with WebGL
Render local WorldCRS84Quad municipality Mapbox Vector Tiles on the GPU in OpenLayers using WebGLVectorTileLayer and flat case expressions.

What this example shows
In a geographic EPSG:4326 view centred on Kraków, official Polish Register of Borders (PRG) municipality vector tiles render directly on the GPU—filling the City of Kraków in vivid blue by matching its administrative code attribute and colouring surrounding communes pale yellow.
When you need it
High-density vector-tile basemaps and regional polygon grids can offload polygon triangulation and stroke rendering from the 2D Canvas CPU pipeline onto the GPU via WebGLVectorTileLayer.
Keeping spatial tile-pyramid streaming (OGCVectorTile + MVT) paired with GPU rendering differs architecturally from loading one monolithic GeoJSON into an untiled WebGL vector layer.
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.
webgl-vector-tiles.html<aol-map height="480px" ariaLabel="WebGL municipality vector tiles around Kraków">
<aol-interaction-default />
<aol-control-defaults [attributionOptions]="attributionOptions" />
<aol-view projection="EPSG:4326" [zoom]="10" [minZoom]="5" [maxZoom]="14">
<aol-coordinate [x]="19.94" [y]="50.1" srid="EPSG:4326" />
</aol-view>
<aol-layer-webglvectortile [style]="style">
<aol-source-ogcvectortile [url]="url" projection="EPSG:4326" [wrapX]="false" [attributions]="credit">
<aol-format-mvt />
</aol-source-ogcvectortile>
</aol-layer-webglvectortile>
</aol-map>webgl-vector-tiles.scss:host {
display: block;
}webgl-vector-tiles.shared.tsimport type { FlatStyle } from 'ol/style/flat.js';
/** Local PRG polygons retain their actual municipality code in MVT attributes. */
export const municipalityStyle: FlatStyle = {
'fill-color': ['case', ['==', ['get', 'code'], '1261011'], '#7aa8ce', '#e6e4ca'],
'stroke-color': '#536879',
'stroke-width': 1,
};
export const municipalityCredit =
'Boundaries: PRG, <a href="https://www.geoportal.gov.pl/pl/dane/panstwowy-rejestr-granic-prg/" target="_blank" rel="noopener">Główny Urząd Geodezji i Kartografii</a>';
export const attributionOptions = { collapsible: false } as const;webgl-vector-tiles.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
FormatMVTComponent,
MapComponent,
SourceOGCVectorTileComponent,
ViewComponent,
} from 'cc-openlayers';
import { LayerWebGLVectorTileComponent } from 'cc-openlayers/webgl';
import { attributionOptions, municipalityCredit, municipalityStyle } from './webgl-vector-tiles.shared';
/** Local municipality MVTs rendered with WebGL and attribute-based flat styling. */
@Component({
selector: 'app-webgl-vector-tiles',
imports: [
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
FormatMVTComponent,
LayerWebGLVectorTileComponent,
MapComponent,
SourceOGCVectorTileComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './webgl-vector-tiles.html',
styleUrl: './webgl-vector-tiles.scss',
})
export class WebglVectorTiles {
protected readonly url = new URL('assets/krakow/municipality-tiles/WorldCRS84Quad.json', document.baseURI).href;
protected readonly style = municipalityStyle;
protected readonly credit = municipalityCredit;
protected readonly attributionOptions = attributionOptions;
} 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.
webgl-vector-tiles.react.tsximport {
Coordinate,
DefaultControls,
DefaultInteractions,
Map,
OGCVectorTileSource,
useMVTFormat,
View,
} from 'cc-openlayers/react';
import { WebGLVectorTileLayer } from 'cc-openlayers/react/webgl';
import { attributionOptions, municipalityCredit, municipalityStyle } from './webgl-vector-tiles.shared';
const tileset = new URL('assets/krakow/municipality-tiles/WorldCRS84Quad.json', document.baseURI).href;
/** Local municipality MVTs rendered with WebGL and attribute-based flat styling. */
export function WebglVectorTilesReact() {
const format = useMVTFormat();
return (
<Map height="480px" ariaLabel="WebGL municipality vector tiles around Kraków">
<DefaultInteractions />
<DefaultControls attributionOptions={attributionOptions} />
<View projection="EPSG:4326" zoom={10} minZoom={5} maxZoom={14}>
<Coordinate x={19.94} y={50.1} srid="EPSG:4326" />
</View>
<WebGLVectorTileLayer style={municipalityStyle}>
<OGCVectorTileSource
url={tileset}
projection="EPSG:4326"
wrapX={false}
attributions={municipalityCredit}
format={format}
/>
</WebGLVectorTileLayer>
</Map>
);
}webgl-vector-tiles.shared.tsimport type { FlatStyle } from 'ol/style/flat.js';
/** Local PRG polygons retain their actual municipality code in MVT attributes. */
export const municipalityStyle: FlatStyle = {
'fill-color': ['case', ['==', ['get', 'code'], '1261011'], '#7aa8ce', '#e6e4ca'],
'stroke-color': '#536879',
'stroke-width': 1,
};
export const municipalityCredit =
'Boundaries: PRG, <a href="https://www.geoportal.gov.pl/pl/dane/panstwowy-rejestr-granic-prg/" target="_blank" rel="noopener">Główny Urząd Geodezji i Kartografii</a>';
export const attributionOptions = { collapsible: false } as const;How the React version works
A WebGL vector-tile layer draws the existing local PRG municipality MVTs around Kraków. A flat expression reads their actual municipality code to fill Kraków blue and neighbouring polygons pale yellow. The source and view both use EPSG:4326 and the finite dataset does not wrap across worlds. The upstream example marks this OpenLayers 10.11 renderer experimental. Its global Mapbox Streets dataset and cartography are replaced by local boundaries. This example demonstrates the WebGL MVT rendering mechanism; it does not reproduce street categories or labels absent from PRG data.
What both versions share
The library adapters create the actual OpenLayers WebGLVectorTile layer. The existing OGC vector-tile source reads WorldCRS84Quad metadata and the same MVT files used by the geographic canvas example. Both adapters share the flat style and source credits; the application adds no renderer or source implementation.
From Angular to React
| Angular | React |
|---|---|
<aol-layer-webglvectortile [style]> | <WebGLVectorTileLayer style> from the WebGL entry point |
<aol-source-ogcvectortile> with a projected MVT format | <OGCVectorTileSource format={useMVTFormat()}> |
<aol-view projection="EPSG:4326"> and a coordinate child | <View projection="EPSG:4326"> with the same coordinate |
Who creates, updates and disposes
The map, layer and source adapters own their OpenLayers instances. The WebGL layer receives flat style updates through the existing shared helper and owns its renderer. Angular destruction and React cleanup detach and dispose the layer and source; React StrictMode replay leaves one live map and releases it on unmount.
Architecture and OpenLayers mechanics
Both Angular and React adapters instantiate OpenLayers’ WebGLVectorTile layer backed by an OGC vector-tile source reading local WorldCRS84Quad metadata and MVT files in EPSG:4326 without world wrapping.
A shared flat style uses a case expression over the real code feature property to distinguish Kraków from neighbouring municipalities, disposing of the map, WebGL renderer and source cleanly on unmount (including React StrictMode replay).
How it works
- Public WebGL vector-tile adapters mount OpenLayers’
WebGLVectorTileclass over the localWorldCRS84QuadOGC MVT tileset. - Style rules query the actual PRG
codeattribute via a flat case expression rather than absent commercial street fields. - Both source matrix and map view run in
EPSG:4326within the bounded zoom range of the local fixture. - Deterministic cleanup releases WebGL contexts, layers and sources cleanly when the component unmounts.
Pitfalls
- Do not confuse
WebGLVectorTile(tiled pyramid streaming) with untiled WebGLVectorLayer—each exercises a distinct OpenLayers GPU pipeline. - Because OpenLayers’ WebGL vector-tile renderer is marked experimental in 10.x, pin minor versions carefully and verify actual rendered pixel colours in real browser E2E checks rather than shallow unit mocks.
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.