Projections · Angular, React and OpenLayers
A WMS in a projection known only by its code
Display GUGiK EPSG:2180 WMS layers and a metric scale line in OpenLayers without loading proj4 by declaring a code-and-units Projection only.

What this example shows
Spanning Lesser Poland and Upper Silesia from Katowice through Kraków (powiat krakowski, powiat wielicki) to Brzesko, GUGiK’s national topographic WMS tiles and single-image magenta county borders render in EPSG:2180 alongside a 10 km scale bar—with zero proj4 library loaded in the bundle.
When you need it
Internal municipal viewers, cadastral kiosks and single-country intranet tools whose services, stored coordinates and views all use the exact same national CRS never need client-side coordinate transformations.
Instantiating a minimal OpenLayers Projection with just code and units drops proj4 completely while keeping WMS tiling and metric scale bars working natively.
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-no-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';wms-no-proj.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import {
ControlScaleLineComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
LayerTileComponent,
MapComponent,
SourceImageWMSComponent,
SourceTileWMSComponent,
ViewComponent,
} from 'cc-openlayers';
import Projection from 'ol/proj/Projection';
import { BOUNDARIES, TOPO } from './wms-no-proj.shared';
/**
* The topographic map and district boundaries around Kraków on a map whose projection is only a code (EPSG:2180) and
* the unit metre: it cannot transform coordinates, yet the tile grid, the WMS requests and the scale line work.
*/
@Component({
selector: 'app-wms-no-proj',
imports: [
ControlScaleLineComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
LayerTileComponent,
MapComponent,
SourceImageWMSComponent,
SourceTileWMSComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-control-scaleline />
<aol-view [zoom]="10" [center]="[567000, 244000]" [projection]="projection" />
<aol-layer-tile>
<aol-source-tilewms
url="${TOPO}"
[params]="{ LAYERS: 'Raster', FORMAT: 'image/jpeg', VERSION: '1.1.1' }"
attributions="Topographic map © GUGiK"
/>
</aol-layer-tile>
<aol-layer-image>
<aol-source-imagewms
url="${BOUNDARIES}"
[params]="{ LAYERS: 'A02_Granice_powiatow', VERSION: '1.1.1' }"
serverType="mapserver"
attributions="Administrative boundaries © GUGiK"
/>
</aol-layer-image>
</aol-map>
`,
})
export class WmsNoProj {
protected readonly projection = new Projection({ code: 'EPSG:2180', units: 'm' });
} 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-no-proj.react.tsximport { useState } from 'react';
import Projection from 'ol/proj/Projection.js';
import {
DefaultControls,
DefaultInteractions,
ImageLayer,
ImageWMSSource,
Map,
ScaleLineControl,
TileLayer,
TileWMSSource,
View,
} from 'cc-openlayers/react';
import { BOUNDARIES, TOPO } from './wms-no-proj.shared';
const CENTER = [567000, 244000];
const TOPO_PARAMS = { LAYERS: 'Raster', FORMAT: 'image/jpeg', VERSION: '1.1.1' };
const BOUNDARIES_PARAMS = { LAYERS: 'A02_Granice_powiatow', VERSION: '1.1.1' };
/**
* The topographic map and district boundaries around Kraków on a map whose projection is only a code (EPSG:2180) and
* the unit metre: it cannot transform coordinates, yet the tile grid, the WMS requests and the scale line work.
*/
export function WmsNoProj() {
const [projection] = useState(() => new Projection({ code: 'EPSG:2180', units: 'm' }));
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<ScaleLineControl />
<View zoom={10} center={CENTER} projection={projection} />
<TileLayer>
<TileWMSSource url={TOPO} params={TOPO_PARAMS} attributions="Topographic map © GUGiK" />
</TileLayer>
<ImageLayer>
<ImageWMSSource
url={BOUNDARIES}
params={BOUNDARIES_PARAMS}
serverType="mapserver"
attributions="Administrative boundaries © GUGiK"
/>
</ImageLayer>
</Map>
);
}wms-no-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';How the React version works
GUGiK's topographic map and district boundaries around Kraków in EPSG:2180 known only by its code and its unit, metres, without any transform.
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 from the example's .shared.ts file, so the logic exists once.
From Angular to React
| Angular | React |
|---|---|
| the projection in a class field | useState(() => new Projection(…)), so it is made once |
<aol-view [center]="[567000, 244000]" [projection]="projection"> | <View center={CENTER} projection={projection}> |
<aol-source-imagewms serverType="mapserver"> | <ImageWMSSource serverType="mapserver"> |
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
new Projection({ code: 'EPSG:2180', units: 'm' }) gives OpenLayers everything required to build tile grids, compute metre scale bars and tag WMS SRS parameters, without registering transform functions.
Because no degree-to-metre transform exists, the view supplies Kraków’s initial position directly in EPSG:2180 metres ([center]="[567000, 244000]"), while A02_Granice_powiatow draws as a single WMS image above tiled topography.
How it works
new Projection({ code: 'EPSG:2180', units: 'm' })defines the national CRS without loading proj4 or transform tables.- View
[center]="[567000, 244000]"specifies central Kraków directly inEPSG:2180planar metres. - With no custom extent set, OpenLayers sizes default zoom steps from a 360°-equivalent metre span (~153 m/px at zoom 10).
- Metric ScaleLine reads ground distance directly from
units: 'm', andA02_Granice_powiatowoverlays crisp county borders.
Pitfalls
- A bare
new Projection({ code: 'EPSG:2180', units: 'm' })defaults to easting-first axes, so configure WMS layers withVERSION: '1.1.1'(always easting-first) unless you also specify axisOrientation: 'neu'. - Every layer, control and coordinate on the map must stay in
EPSG:2180—passing degree coordinates throws No transform available between EPSG:4326 and EPSG:2180, and a reprojected EPSG:3857 tile layer fails on No transform available between EPSG:2180 and EPSG:3857.
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.