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.

Poland's voivodeships at zoom 7 around Kraków, their boundaries in pink over OpenStreetMap.
A screenshot of the example. Voivodeships: Państwowy Rejestr Granic © GUGiK. Map data © OpenStreetMap contributors.

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

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] to 0 displays 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: true asks a GeoServer/GeoWebCache backend for 3×3 meta-tiles; servers that do not know the parameter ignore it.

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.