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.

The landscape parks around Kraków at zoom 9 as yellow areas with their names, such as Dolinki Krakowskie and Tenczyński Park Krajobrazowy, over OpenStreetMap.
A screenshot of the example. Landscape parks: Generalna Dyrekcja Ochrony Środowiska (GDOŚ). Map data © OpenStreetMap contributors.

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

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 createLoader configures aol-source-image with FORMAT: 'image/svg+xml'.
  • Supplying load: load preserves 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: 1 requests 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.

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.