Projections · Angular, React and OpenLayers
A tiled WMS in the Polish 1992 grid
Run a native Polish 1992 grid (EPSG:2180) OpenLayers View with proj4, tiled GUGiK WMS 1.1.1 layers and MapServer HiDPI boundary scaling.

What this example shows
Across southern and central Poland from the western border to Lublin and from the Beskids to Warsaw, both the OpenLayers View and two tiled GUGiK WMS layers—topographic basemap and magenta voivodeship borders—operate natively in the Polish 1992 national grid (EPSG:2180) with a true-metre scale line in the corner.
When you need it
Polish surveying, urban planning (MPZP), environmental impact and cadastral systems work natively in PUWG 1992 (EPSG:2180) or PUWG 2000 so server-rendered national WMS layers stay 100% unwarped and map units represent true ground metres.
Configuring proj4 together with an explicit national extent calibrates zoom levels, tile grids and coordinate transforms cleanly.
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-custom-proj.shared.ts/** The topographic map service. */
export const TOPO = 'https://mapy.geoportal.gov.pl/wss/service/img/guest/TOPO/MapServer/WMSServer';
/** The administrative boundaries service. */
export const BOUNDARIES = 'https://mapy.geoportal.gov.pl/wss/service/PZGIK/PRG/WMS/AdministrativeBoundaries';
/** The validity extent of EPSG:2180 around Poland; it also sets the tile grid of zoom level 0. */
export const EXTENT = [100000, 160000, 800000, 880000];wms-custom-proj.tsimport { ChangeDetectionStrategy, Component, inject, PendingTasks, signal } from '@angular/core';
import {
ControlScaleLineComponent,
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerTileComponent,
loadProj4,
MapComponent,
registerProjectionDefinitions,
SourceTileWMSComponent,
ViewComponent,
} from 'cc-openlayers';
import { get as getProjection } from 'ol/proj';
import { BOUNDARIES, EXTENT, TOPO } from './wms-custom-proj.shared';
/**
* Poland's topographic map and voivodeship boundaries on a map in the national grid (EPSG:2180), registered through
* proj4 before the map starts.
*/
@Component({
selector: 'app-wms-custom-proj',
imports: [
ControlScaleLineComponent,
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerTileComponent,
MapComponent,
SourceTileWMSComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@if (ready()) {
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-control-scaleline units="metric" />
<aol-view [zoom]="2" [extent]="extent" projection="EPSG:2180">
<aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
</aol-view>
<aol-layer-tile [extent]="extent">
<aol-source-tilewms
url="${TOPO}"
[params]="{ LAYERS: 'Raster', FORMAT: 'image/jpeg', VERSION: '1.1.1' }"
attributions="Topographic map © GUGiK"
/>
</aol-layer-tile>
<aol-layer-tile [extent]="extent">
<aol-source-tilewms
url="${BOUNDARIES}"
[params]="{ LAYERS: 'A01_Granice_wojewodztw', VERSION: '1.1.1' }"
serverType="mapserver"
attributions="Administrative boundaries © GUGiK"
/>
</aol-layer-tile>
</aol-map>
}
`,
})
export class WmsCustomProj {
/** True once EPSG:2180 is known to OpenLayers, which the view needs when it is created. */
readonly ready = signal(false);
protected readonly extent = EXTENT;
constructor() {
void inject(PendingTasks).run(async () => {
try {
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',
});
getProjection('EPSG:2180')?.setExtent(this.extent);
this.ready.set(true);
} catch (error) {
console.error('The projection could not be loaded', error);
}
});
}
} 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-custom-proj.react.tsximport { useEffect, useState } from 'react';
import { get as getProjection } from 'ol/proj.js';
import {
Coordinate,
DefaultControls,
DefaultInteractions,
Map,
ScaleLineControl,
TileLayer,
TileWMSSource,
View,
} from 'cc-openlayers/react';
import { loadProj4, ProjectionCodeDefinition, registerProjectionDefinitions } from 'cc-openlayers/core';
import { BOUNDARIES, EXTENT, TOPO } from './wms-custom-proj.shared';
const TOPO_PARAMS = { LAYERS: 'Raster', FORMAT: 'image/jpeg', VERSION: '1.1.1' };
const BOUNDARIES_PARAMS = { LAYERS: 'A01_Granice_wojewodztw', VERSION: '1.1.1' };
/**
* Poland's topographic map and voivodeship boundaries on a map in the national grid (EPSG:2180), registered through
* proj4 before the map starts.
*/
export function WmsCustomProj() {
/** True once EPSG:2180 is known to OpenLayers, which the view needs when it is created. */
const [ready, setReady] = useState(false);
useEffect(() => {
void loadProj4()
.then((proj4) => {
registerProjectionDefinitions(proj4, { 'EPSG:2180': ProjectionCodeDefinition.Pl1992 });
getProjection('EPSG:2180')?.setExtent(EXTENT);
setReady(true);
})
.catch((error: unknown) => console.error('The projection could not be loaded', error));
}, []);
if (!ready) return null;
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<ScaleLineControl units="metric" />
<View zoom={2} extent={EXTENT} projection="EPSG:2180">
<Coordinate x={19.9368} y={50.0614} srid="EPSG:4326" />
</View>
<TileLayer extent={EXTENT}>
<TileWMSSource url={TOPO} params={TOPO_PARAMS} attributions="Topographic map © GUGiK" />
</TileLayer>
<TileLayer extent={EXTENT}>
<TileWMSSource
url={BOUNDARIES}
params={BOUNDARIES_PARAMS}
serverType="mapserver"
attributions="Administrative boundaries © GUGiK"
/>
</TileLayer>
</Map>
);
}wms-custom-proj.shared.ts/** The topographic map service. */
export const TOPO = 'https://mapy.geoportal.gov.pl/wss/service/img/guest/TOPO/MapServer/WMSServer';
/** The administrative boundaries service. */
export const BOUNDARIES = 'https://mapy.geoportal.gov.pl/wss/service/PZGIK/PRG/WMS/AdministrativeBoundaries';
/** The validity extent of EPSG:2180 around Poland; it also sets the tile grid of zoom level 0. */
export const EXTENT = [100000, 160000, 800000, 880000];How the React version works
GUGiK's topographic map and voivodeship boundaries as tiled WMS layers in a view in the Polish 1992 grid, EPSG:2180, defined through proj4, with a metric scale line.
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 both service URLs and the extent of the grid 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, a failed load logged, and return null until then |
<aol-view [zoom]="2" [extent]="extent" projection="EPSG:2180"> | <View zoom={2} extent={EXTENT} projection="EPSG:2180"> |
[params] written in the template | TOPO_PARAMS and BOUNDARIES_PARAMS defined once at module level |
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. After the registration the effect sets the extent of the projection, before the view is created. React reads the definition from ProjectionCodeDefinition in cc-openlayers/core, which holds the same string Angular writes out.
Architecture and OpenLayers mechanics
registerProjectionDefinitions registers EPSG:2180 via proj4 and getProjection('EPSG:2180')?.setExtent(this.extent) defines the national bounding box before @if (ready()) creates the map.
The EPSG:2180 view clamps navigation inside [extent]="extent", while both tiled WMS layers request VERSION: '1.1.1' (guaranteeing easting-first BBOX order matching plain proj4 definitions) and the boundaries layer adds serverType="mapserver" for sharp Retina MAP_RESOLUTION line widths.
How it works
registerProjectionDefinitionsregistersEPSG:2180andgetProjection('EPSG:2180')?.setExtent(this.extent)calibrates its zoom pyramid before@if (ready()).- View
[extent]="extent"keeps the entire viewport inside Poland’s national grid bounds. serverType="mapserver"requests high-DPI boundary tiles with matching MAP_RESOLUTION, layered over standard topographic WMS tiles.proj4supplies bidirectionalEPSG:4326↔EPSG:2180transforms so initial centre coordinates can still be written in degrees.
Pitfalls
- Plain
proj4definitions without +axis=neu treatEPSG:2180as easting-first, whereas WMS 1.3.0 expects northing-first forEPSG:2180—specifyingVERSION: '1.1.1'forces easting-first BBOX ordering across all coordinate systems (or see wms-image-custom-proj for an axisOrientation option of neu under WMS 1.3.0). - OpenLayers derives zoom 0 of a custom projection from projection.getExtent(): changing that extent array changes the ground scale of every integer zoom level.
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.