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.

GUGiK's topographic map around Kraków from Katowice in the west to Brzesko in the east, with the district boundaries in magenta and their names, powiat krakowski and powiat wielicki among them, and a 10 km scale line in the bottom left corner.
A screenshot of the example. Topographic map and administrative boundaries © GUGiK.

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

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 in EPSG:2180 planar 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', and A02_Granice_powiatow overlays crisp county borders.

Pitfalls

  • A bare new Projection({ code: 'EPSG:2180', units: 'm' }) defaults to easting-first axes, so configure WMS layers with VERSION: '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.

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.