Projections · Angular, React and OpenLayers
A single image WMS in the Polish 1992 grid
Request single-image WMS 1.3.0 maps in Polish 1992 grid (EPSG:2180) using OpenLayers Projection axisOrientation neu and GeoServer HiDPI DPI.

What this example shows
Across Kraków and the Jurassic valleys to the west—highlighting Tenczyński and Bielańsko-Tyniecki landscape parks and buffer zones in yellow—GUGiK’s topographic base map and GDOŚ’s conservation overlays load as unbroken single-viewport WMS 1.3.0 images natively in EPSG:2180 with a 5 km metric scale line.
When you need it
When Polish WMS 1.3.0 services render curved buffer labels and national topographic sheets in EPSG:2180, single-image GetMap avoids cut-off tile labels while keeping true planar metres for engineering measurements.
Configuring axisOrientation: 'neu' explicitly on the OpenLayers Projection lets you use modern OGC WMS 1.3.0 natively instead of downgrading requests to legacy WMS 1.1.1.
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-custom-proj.shared.tsimport Projection from 'ol/proj/Projection.js';
/** The area both layers are limited to, around Poland in the national grid. */
export const EXTENT = [100000, 100000, 900000, 950000];
/** EPSG:2180 with its units, axis order and validity extent, for the view. */
export function createNationalGridProjection(): Projection {
return new Projection({
code: 'EPSG:2180',
units: 'm',
// The grid names northing first, so WMS 1.3.0 takes the bounding box in that order.
axisOrientation: 'neu',
extent: [144693.28, 125837.02, 876500.36, 908411.19],
});
}wms-image-custom-proj.tsimport { ChangeDetectionStrategy, Component, inject, PendingTasks, signal } from '@angular/core';
import {
ControlScaleLineComponent,
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
loadProj4,
MapComponent,
registerProjectionDefinitions,
SourceImageWMSComponent,
ViewComponent,
} from 'cc-openlayers';
import { createNationalGridProjection, EXTENT } from './wms-image-custom-proj.shared';
// Transparent Proj4js support:
//
// EPSG:2180 is known to Proj4js because its definition is registered by
// calling registerProjectionDefinitions(). Now when we create an
// ol/proj/Projection instance with the 'EPSG:2180' code, OpenLayers will pick
// up the transform functions from Proj4js.
//
// Note that we are setting the projection's extent here, which is used to
// determine the view resolution for zoom level 0. Recommended values for a
// projection's validity extent can be found at https://epsg.io/.
/**
* GUGiK's topographic map of Kraków and GDOŚ's landscape parks and nature reserves over it, both as single WMS images
* in the Polish national grid (EPSG:2180), registered through proj4.
*/
@Component({
selector: 'app-wms-image-custom-proj',
imports: [
ControlScaleLineComponent,
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
MapComponent,
SourceImageWMSComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@if (ready()) {
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-control-scaleline />
<aol-view [projection]="projection" [zoom]="6" [extent]="extent">
<aol-coordinate [x]="19.9373" [y]="50.0617" srid="EPSG:4326" />
</aol-view>
<aol-layer-image [extent]="extent">
<aol-source-imagewms
url="https://mapy.geoportal.gov.pl/wss/service/img/guest/TOPO/MapServer/WMSServer"
crossOrigin="anonymous"
[params]="{ LAYERS: 'Raster', FORMAT: 'image/jpeg' }"
attributions="Topographic map © GUGiK"
/>
</aol-layer-image>
<aol-layer-image [extent]="extent">
<aol-source-imagewms
url="https://sdi.gdos.gov.pl/wms"
crossOrigin="anonymous"
[params]="{ LAYERS: 'GDOS:ParkiKrajobrazowe,GDOS:Rezerwaty' }"
serverType="geoserver"
attributions="Landscape parks and nature reserves © GDOŚ"
/>
</aol-layer-image>
</aol-map>
}
`,
})
export class WmsImageCustomProj {
/** True once EPSG:2180 is known to Proj4js, before the view is created. */
readonly ready = signal(false);
protected readonly projection = createNationalGridProjection();
protected readonly extent = EXTENT;
constructor() {
void inject(PendingTasks).run(async () => {
registerProjectionDefinitions(await loadProj4(), {
'EPSG:2180':
'+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m +no_defs',
});
this.ready.set(true);
});
}
} 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-custom-proj.react.tsximport { useEffect, useState } from 'react';
import {
Coordinate,
DefaultControls,
DefaultInteractions,
ImageLayer,
ImageWMSSource,
Map,
ScaleLineControl,
View,
} from 'cc-openlayers/react';
import { loadProj4, ProjectionCodeDefinition, registerProjectionDefinitions } from 'cc-openlayers/core';
import { createNationalGridProjection, EXTENT } from './wms-image-custom-proj.shared';
// Transparent Proj4js support:
//
// EPSG:2180 is known to Proj4js because its definition is registered by
// calling registerProjectionDefinitions(). Now when we create an
// ol/proj/Projection instance with the 'EPSG:2180' code, OpenLayers will pick
// up the transform functions from Proj4js.
//
// Note that we are setting the projection's extent here, which is used to
// determine the view resolution for zoom level 0. Recommended values for a
// projection's validity extent can be found at https://epsg.io/.
const TOPO_PARAMS = { LAYERS: 'Raster', FORMAT: 'image/jpeg' };
const PARKS_PARAMS = { LAYERS: 'GDOS:ParkiKrajobrazowe,GDOS:Rezerwaty' };
/**
* GUGiK's topographic map of Kraków and GDOŚ's landscape parks and nature reserves over it, both as single WMS images
* in the Polish national grid (EPSG:2180), registered through proj4.
*/
export function WmsImageCustomProj() {
/** True once EPSG:2180 is known to Proj4js, before the view is created. */
const [ready, setReady] = useState(false);
const [projection] = useState(createNationalGridProjection);
useEffect(() => {
void loadProj4().then((proj4) => {
registerProjectionDefinitions(proj4, { 'EPSG:2180': ProjectionCodeDefinition.Pl1992 });
setReady(true);
});
}, []);
if (!ready) return null;
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<ScaleLineControl />
<View projection={projection} zoom={6} extent={EXTENT}>
<Coordinate x={19.9373} y={50.0617} srid="EPSG:4326" />
</View>
<ImageLayer extent={EXTENT}>
<ImageWMSSource
url="https://mapy.geoportal.gov.pl/wss/service/img/guest/TOPO/MapServer/WMSServer"
crossOrigin="anonymous"
params={TOPO_PARAMS}
attributions="Topographic map © GUGiK"
/>
</ImageLayer>
<ImageLayer extent={EXTENT}>
<ImageWMSSource
url="https://sdi.gdos.gov.pl/wms"
crossOrigin="anonymous"
params={PARKS_PARAMS}
serverType="geoserver"
attributions="Landscape parks and nature reserves © GDOŚ"
/>
</ImageLayer>
</Map>
);
}wms-image-custom-proj.shared.tsimport Projection from 'ol/proj/Projection.js';
/** The area both layers are limited to, around Poland in the national grid. */
export const EXTENT = [100000, 100000, 900000, 950000];
/** EPSG:2180 with its units, axis order and validity extent, for the view. */
export function createNationalGridProjection(): Projection {
return new Projection({
code: 'EPSG:2180',
units: 'm',
// The grid names northing first, so WMS 1.3.0 takes the bounding box in that order.
axisOrientation: 'neu',
extent: [144693.28, 125837.02, 876500.36, 908411.19],
});
}How the React version works
GUGiK's topographic map of Kraków and GDOŚ's landscape parks and reserves as single WMS images in EPSG:2180, a projection set up with proj4.
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. Both versions import the area both layers are limited to and createNationalGridProjection, the projection with northing first from the example's .shared.ts file, so the logic exists once.
From Angular to React
| Angular | React |
|---|---|
ready signal set inside PendingTasks.run and @if (ready()) | useState(false) set after loadProj4() resolves, and return null until then |
| the projection in a class field | useState(createNationalGridProjection), so it is made once |
<aol-layer-image [extent]="extent"> with <aol-source-imagewms> | <ImageLayer extent={EXTENT}> with <ImageWMSSource> |
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. loadProj4 and the registration of EPSG:2180 run in a useEffect with no dependencies; the component renders nothing until a state flag says the projection is known, as @if (ready()) does around PendingTasks.run in Angular. Under StrictMode the effect runs twice and registers the same definition twice, which changes nothing. React reads the definition from ProjectionCodeDefinition in cc-openlayers/core, which holds the same string Angular writes out.
Architecture and OpenLayers mechanics
projection constructs new Projection({ for EPSG:2180 in metres with axisOrientation: 'neu' (North, East, Up) and extent bounds, backed by proj4 math via registerProjectionDefinitions.
Because the projection declares northing-first axes, each aol-source-imagewms automatically serialises WMS 1.3.0 BBOX values northing-first as GUGiK and GDOŚ (GDOS:ParkiKrajobrazowe,GDOS:Rezerwaty, serverType="geoserver") expect.
How it works
projectioninstantiatesnew Projection({forEPSG:2180withaxisOrientation: 'neu', paired withregisterProjectionDefinitions.- The projection’s own validity extent sets the zoom-0 scale (
[zoom]="6"≈ 48 m/px), while a separate view extent clips navigation. - Each
aol-source-imagewmssends WMS 1.3.0 requests with northing-first bounding boxes matchingaxisOrientation: 'neu'. serverType="geoserver"scales GDOŚ’sGDOS:ParkiKrajobrazowe,GDOS:Rezerwatyoverlay to screen pixel density with matching DPI.
Pitfalls
- Registering
EPSG:2180from a bareproj4string alone defaultsaxisOrientationto 'enu' (East-first), causing WMS 1.3.0 BBOX coordinates to arrive swapped and miss Poland completely—always setaxisOrientation: 'neu'(or +axis=neu) for WMS 1.3.0. - Default 1.5× single-image overscan absorbs short drags without network traffic, while zooms and wider pans request a fresh viewport render.
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.