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.

PRG municipality polygons around Kraków, with the city filled blue and neighbouring municipalities pale yellow.
A screenshot of the example. Municipality boundaries: Państwowy Rejestr Granic, Główny Urząd Geodezji i Kartografii.

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

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’ WebGLVectorTile class over the local WorldCRS84Quad OGC MVT tileset.
  • Style rules query the actual PRG code attribute via a flat case expression rather than absent commercial street fields.
  • Both source matrix and map view run in EPSG:4326 within 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.

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.