Tile and image services · Angular, React and OpenLayers
A WMS layer as tiles
Stream Polish voivodeship boundaries from GUGiK as 256-pixel WMS tiles over OpenStreetMap using CORS-enabled WebGL tile layers in Angular.

What this example shows
Centred on Kraków at zoom 7, Polish voivodeship borders render in crisp pink from GUGiK’s national register of boundaries as 256 × 256 WMS tiles composited over OpenStreetMap—with both layers accelerated on the GPU through WebGL tile layers.
When you need it
When users pan back and forth repeatedly across complex administrative, geological or cadastral WMS services, tiled GetMap requests allow browser HTTP caches and CDNs to reuse every visited 256-pixel square instantaneously.
Pairing tiled WMS with WebGL tile rendering keeps multi-layer pan performance smooth at 60 fps even on high-resolution monitors.
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.
wms-tiled.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import { transformExtent } from 'ol/proj';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
MapComponent,
SourceOsmComponent,
SourceTileWMSComponent,
ViewComponent,
} from 'cc-openlayers';
import { LayerWebGLTileComponent } from 'cc-openlayers/webgl';
/** Poland's voivodeships from the national register of boundaries (PRG) as a tiled WMS over the street map. */
@Component({
selector: 'app-wms-tiled',
imports: [
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerWebGLTileComponent,
MapComponent,
SourceOsmComponent,
SourceTileWMSComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-view [zoom]="7">
<aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
</aol-view>
<aol-layer-webgltile><aol-source-osm /></aol-layer-webgltile>
<aol-layer-webgltile [extent]="poland">
<!-- The voivodeships are transparent, so the tiles do not fade in. -->
<aol-source-tilewms
url="https://mapy.geoportal.gov.pl/wss/service/PZGIK/PRG/WMS/AdministrativeBoundaries"
[params]="{ LAYERS: 'A01_Granice_wojewodztw', TILED: true }"
crossOrigin="anonymous"
[transition]="0"
attributions='© <a href="https://www.geoportal.gov.pl/" target="_blank">GUGiK</a> (PRG)'
/>
</aol-layer-webgltile>
</aol-map>
`,
})
export class WmsTiled {
/** Poland's bounding box: no tiles are asked for outside it. */
protected readonly poland = transformExtent([14.07, 49.0, 24.15, 54.84], 'EPSG:4326', 'EPSG:3857');
} 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.
wms-tiled.react.tsximport {
Coordinate,
DefaultControls,
DefaultInteractions,
Map,
OSMSource,
TileWMSSource,
View,
} from 'cc-openlayers/react';
import { WebGLTileLayer } from 'cc-openlayers/react/webgl';
import { transformExtent } from 'ol/proj.js';
/** Poland's bounding box: no tiles are asked for outside it. */
const poland = transformExtent([14.07, 49.0, 24.15, 54.84], 'EPSG:4326', 'EPSG:3857');
const params = { LAYERS: 'A01_Granice_wojewodztw', TILED: true };
/** Poland's voivodeships from the national register of boundaries (PRG) as a tiled WMS over the street map. */
export function WmsTiled() {
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View zoom={7}>
<Coordinate x={19.9368} y={50.0614} srid="EPSG:4326" />
</View>
<WebGLTileLayer>
<OSMSource />
</WebGLTileLayer>
<WebGLTileLayer extent={poland}>
{/* The voivodeships are transparent, so the tiles do not fade in. */}
<TileWMSSource
url="https://mapy.geoportal.gov.pl/wss/service/PZGIK/PRG/WMS/AdministrativeBoundaries"
params={params}
crossOrigin="anonymous"
transition={0}
attributions='© <a href="https://www.geoportal.gov.pl/" target="_blank">GUGiK</a> (PRG)'
/>
</WebGLTileLayer>
</Map>
);
}How the React version works
Voivodeships from GUGiK's WMS as tiles over the street map, both layers drawn by WebGL; the tiles are transparent, so without a transition.
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-layer-webgltile> | <WebGLTileLayer> |
<aol-source-tilewms [params] [transition]="0"> | <TileWMSSource params transition={0}> |
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-tilewms slices the viewport along the default Web Mercator 256-pixel pyramid and issues parallel GetMap requests for the layer specified in [params]. Setting crossOrigin="anonymous" clears CORS texture security for WebGL upload, [transition] of 0 prevents transparent pink lines from doubling over coarser parent tiles during fades, and [extent] blocks out-of-country requests.
How it works
- aol-source-tilewms dispatches 256-pixel GetMap tile requests aligned with the view’s Web Mercator grid using
[params]. crossOrigin="anonymous"enables CORS pixel access required to upload WMS tiles as WebGL textures.- Setting
[transition]to0displays transparent boundary tiles immediately without flashing coarse parent strokes underneath. - Layer
[extent]restricts tile requests strictly to Poland’s projected bounding box.
Pitfalls
- Independent per-tile GetMap rendering can clip or duplicate polygon labels across tile seams unless the server renders buffered meta-tiles.
- Passing the vendor hint
TILED: trueasks a GeoServer/GeoWebCache backend for 3×3 meta-tiles; servers that do not know the parameter ignore it.
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.