Tile and image services · Angular, React and OpenLayers

A WMS layer as one image

Render GUGiK administrative boundaries around Kraków as a single viewport-sized WMS GetMap image in OpenLayers with live image load events.

A map of the counties around Kraków with their borders and names in pink over OpenStreetMap, and the status Loaded below it.
A screenshot of the example. Administrative boundaries © GUGiK. Map data © OpenStreetMap contributors.

What this example shows

Over an OpenStreetMap backdrop of the Kraków region, Polish commune, county and voivodeship borders and names render in crisp pink from GUGiK’s national OGC Web Map Service as one unified image per settled view, paired with a live Loading / Loaded status line below.

When you need it

OGC WMS remains the backbone of European INSPIRE and national spatial data infrastructures, publishing authoritative administrative, cadastral and environmental layers.

Fetching one GetMap image per viewport guarantees unbroken polygon labels across the entire screen—avoiding the sliced or repeated text common in uncached tiled WMS layers.

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.

image-wms.ts
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import {
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  LayerImageComponent,
  LayerTileComponent,
  MapComponent,
  SourceImageWMSComponent,
  SourceOsmComponent,
  ViewComponent,
} from 'cc-openlayers';

/** A single-image WMS layer (the boundaries of the communes, counties and voivodeships around Kraków, GUGiK) over OpenStreetMap, with the image's load status. */
@Component({
  selector: 'app-image-wms',
  imports: [
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerImageComponent,
    LayerTileComponent,
    MapComponent,
    SourceImageWMSComponent,
    SourceOsmComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px">
      <aol-interaction-default />
      <aol-control-defaults />
      <aol-view [zoom]="9"><aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" /></aol-view>
      <aol-layer-tile><aol-source-osm /></aol-layer-tile>
      <aol-layer-image>
        <aol-source-imagewms
          url="https://mapy.geoportal.gov.pl/wss/service/PZGIK/PRG/WMS/AdministrativeBoundaries"
          [params]="{ LAYERS: 'A03_Granice_gmin,A02_Granice_powiatow,A01_Granice_wojewodztw' }"
          [ratio]="1"
          attributions="Administrative boundaries © GUGiK"
          (imageLoadStart)="status.set('Loading…')"
          (imageLoadEnd)="status.set('Loaded')"
        />
      </aol-layer-image>
    </aol-map>
    <div class="example-controls">
      <output>{{ status() }}</output>
    </div>
  `,
})
export class ImageWms {
  readonly status = signal('–');
}

Architecture and OpenLayers mechanics

aol-source-imagewms constructs a single OGC GetMap HTTP request whenever panning or zooming settles, passing the layer names declared in [params]. Configuring [ratio]="1" requests exact 1:1 viewport dimensions instead of the default 1.5× overscan margin, while (imageLoadStart) and (imageLoadEnd) track network state and attributions registers GUGiK’s legal credit.

How it works

  • aol-source-imagewms dispatches one OGC GetMap image request per settled viewport using the layer list in [params].
  • [ratio]="1" matches the requested image size exactly to the viewport rather than adding a 1.5× pan margin.
  • (imageLoadStart) and (imageLoadEnd) update the reactive load status indicator below the map.
  • attributions pipes the national registry’s data credit into OpenLayers’ attribution control.

Pitfalls

  • Because every pan or zoom triggers a fresh uncached GetMap render on the server, switch to tiled WMS (aol-source-tilewms) when users pan back and forth repeatedly over slow-rendering services.
  • Always verify in GetCapabilities that the WMS server supports your view’s CRS (such as EPSG:3857) before requesting images.

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.