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.

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.tsimport { 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('–');
} 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.
image-wms.react.tsximport { useMemo, useState } from 'react';
import {
Coordinate,
DefaultControls,
DefaultInteractions,
ImageLayer,
ImageWMSSource,
Map,
OSMSource,
TileLayer,
View,
} from 'cc-openlayers/react';
/** 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. */
export function ImageWms() {
const [status, setStatus] = useState('–');
const params = useMemo(() => ({ LAYERS: 'A03_Granice_gmin,A02_Granice_powiatow,A01_Granice_wojewodztw' }), []);
return (
<>
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View zoom={9}>
<Coordinate x={19.9368} y={50.0614} srid="EPSG:4326" />
</View>
<TileLayer>
<OSMSource />
</TileLayer>
<ImageLayer>
<ImageWMSSource
url="https://mapy.geoportal.gov.pl/wss/service/PZGIK/PRG/WMS/AdministrativeBoundaries"
params={params}
ratio={1}
attributions="Administrative boundaries © GUGiK"
onImageLoadStart={() => setStatus('Loading…')}
onImageLoadEnd={() => setStatus('Loaded')}
/>
</ImageLayer>
</Map>
<div className="example-controls">
<output>{status}</output>
</div>
</>
);
}How the React version works
Municipal, county and voivodeship borders from GUGiK's WMS as one image over OpenStreetMap, with a loading status.
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-source-imagewms [params]> | <ImageWMSSource params> with a module constant |
(imageLoadStart), (imageLoadEnd) on the source | onImageLoadStart, onImageLoadEnd |
signal('') with the status | useState('') |
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-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-imagewmsdispatches 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.attributionspipes 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.
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.