Tile and image services · Angular, React and OpenLayers
A WMS image in SVG
Load GDOŚ landscape parks around Kraków from a GeoServer WMS in vector image/svg+xml format so boundaries stay crisp while zooming the map.

What this example shows
Around Kraków at zoom 9, protected landscape parks—including Dolinki Krakowskie and Tenczyński Park Krajobrazowy—render in warm yellow with crisp typographic labels served by GDOŚ’s GeoServer WMS as a scalable image/svg+xml document rather than a fixed-pixel PNG.
During continuous wheel or pinch zooms, the browser re-rasterises the cached SVG vector paths cleanly on every intermediate frame until the settled zoom fetches the next scale-adjusted SVG.
When you need it
Standard PNG GetMap images visibly pixelate while a user zooms in before the new image finishes downloading, especially on crisp polygon boundaries and technical labels.
When a GeoServer or MapServer WMS advertises image/svg+xml output for moderate-complexity vector layers, requesting SVG keeps intermediate zoom frames razor-sharp.
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-image-svg.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
LayerTileComponent,
MapComponent,
SourceImageComponent,
SourceOsmComponent,
ViewComponent,
} from 'cc-openlayers';
import { load } from 'ol/Image';
import { createLoader } from 'ol/source/wms';
/**
* A WMS image in SVG: the GeoServer of Poland's General Directorate for Environmental Protection draws the landscape
* parks around Kraków as vectors. Loaded with `load`, the answer stays an image element instead of a decoded bitmap,
* so the browser redraws it sharp while zooming; it is asked for only within the extent of Lesser Poland.
*/
@Component({
selector: 'app-wms-image-svg',
imports: [
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
LayerTileComponent,
MapComponent,
SourceImageComponent,
SourceOsmComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-view [zoom]="9">
<aol-coordinate [x]="19.9373" [y]="50.0617" srid="EPSG:4326" />
</aol-view>
<aol-layer-tile><aol-source-osm /></aol-layer-tile>
<aol-layer-image [extent]="[2122863, 6303756, 2384463, 6536822]">
<aol-source-image [loader]="loader" attributions="Landscape parks: GDOŚ" />
</aol-layer-image>
</aol-map>
`,
})
export class WmsImageSvg {
protected readonly loader = createLoader({
url: 'https://sdi.gdos.gov.pl/wms',
params: { LAYERS: 'GDOS:ParkiKrajobrazowe', FORMAT: 'image/svg+xml' },
ratio: 1,
load: load,
});
} 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-image-svg.react.tsximport {
Coordinate,
DefaultControls,
DefaultInteractions,
ImageLayer,
ImageSource,
Map,
OSMSource,
TileLayer,
View,
} from 'cc-openlayers/react';
import { load } from 'ol/Image.js';
import { createLoader } from 'ol/source/wms.js';
const extent = [2122863, 6303756, 2384463, 6536822];
const loader = createLoader({
url: 'https://sdi.gdos.gov.pl/wms',
params: { LAYERS: 'GDOS:ParkiKrajobrazowe', FORMAT: 'image/svg+xml' },
ratio: 1,
load: load,
});
/**
* A WMS image in SVG: the GeoServer of Poland's General Directorate for Environmental Protection draws the landscape
* parks around Kraków as vectors. Loaded with `load`, the answer stays an image element instead of a decoded bitmap,
* so the browser redraws it sharp while zooming; it is asked for only within the extent of Lesser Poland.
*/
export function WmsImageSvg() {
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View zoom={9}>
<Coordinate x={19.9373} y={50.0617} srid="EPSG:4326" />
</View>
<TileLayer>
<OSMSource />
</TileLayer>
<ImageLayer extent={extent}>
<ImageSource loader={loader} attributions="Landscape parks: GDOŚ" />
</ImageLayer>
</Map>
);
}How the React version works
Landscape parks around Kraków from the GDOŚ GeoServer as an SVG image; load from ol/Image keeps the image element, so the browser draws it sharp when zoomed.
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. createLoader from ol/source/wms creates the loading function once, when the module loads.
From Angular to React
| Angular | React |
|---|---|
<aol-source-image [loader]> | <ImageSource loader={loader}> |
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
createLoader from OpenLayers’ WMS module builds a custom image loader for aol-source-image requesting FORMAT: 'image/svg+xml' and ratio: 1. Passing custom load: load hands the live HTMLImageElement straight to the layer without pre-baking it into a fixed-resolution bitmap canvas—allowing the browser’s native SVG engine to scale paths sharply at any intermediate zoom.
Layer [extent] restricts requests to Lesser Poland’s Web Mercator bounding box.
How it works
- OpenLayers’ WMS
createLoaderconfiguresaol-source-imagewithFORMAT: 'image/svg+xml'. - Supplying
load: loadpreserves the vector-backed image element directly instead of decoding it into a fixed-size raster bitmap. - Layer
[extent]confines GetMap requests to the Lesser Poland (Małopolska) bounding box in Web Mercator. ratio: 1requests exact viewport coverage rather than the default 1.5× overscan.
Pitfalls
- Complex WMS layers containing tens of thousands of polygon vertices produce huge XML payloads that cost browsers far more CPU to parse and paint than a compressed PNG—reserve SVG WMS output for clean administrative or conservation outlines.
- Check <GetMap><Format> inside the server’s GetCapabilities XML first, as many WMS servers only publish PNG and JPEG.
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.