Projections · Angular, React and OpenLayers

A map in EPSG:4326

Configure a native geographic EPSG:4326 OpenLayers map view over southern Poland with WMS 1.3.0 JPEG tiles and an arc-degree ScaleLine control.

GUGiK's topographic map of southern Poland from Opole to Rzeszów with Kraków in the middle, the Upper Silesian towns to its west, Częstochowa and Kielce to the north and the Tatras in the south, and a scale line in degrees in the bottom left corner.
A screenshot of the example. Topographic map © GUGiK.

What this example shows

Spanning southern Poland from Opole and Upper Silesia through Kraków to Rzeszów and the Tatra Mountains at [zoom]="8", GUGiK’s national topographic WMS streams natively in geographic EPSG:4326 degrees—paired with a bottom-left scale line calibrated in arc-degrees, minutes and seconds.

When you need it

INSPIRE compliance portals, defence/aviation systems, global meteorological dashboards and scientific catalogues built natively around EPSG:4326 WGS 84 services work directly in decimal degrees without Spherical Mercator projection distortion.

Matching projection="EPSG:4326" on the View with an EPSG:4326-capable WMS avoids client-side raster reprojection altogether.

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.

epsg-4326.ts
import { ChangeDetectionStrategy, Component } from '@angular/core';
import {
  ControlScaleLineComponent,
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  LayerTileComponent,
  MapComponent,
  SourceTileWMSComponent,
  ViewComponent,
} from 'cc-openlayers';

/** A map whose view is in EPSG:4326, showing GUGiK's topographic map WMS with a scale line in degrees. */
@Component({
  selector: 'app-epsg-4326',
  imports: [
    ControlScaleLineComponent,
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerTileComponent,
    MapComponent,
    SourceTileWMSComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px">
      <aol-interaction-default />
      <aol-control-defaults />
      <aol-control-scaleline units="degrees" />
      <aol-view projection="EPSG:4326" [zoom]="8">
        <aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
      </aol-view>
      <aol-layer-tile>
        <!-- JPEG tiles: in PNG, OpenLayers asks for a transparent background, and the map's open land comes out empty. -->
        <aol-source-tilewms
          url="https://mapy.geoportal.gov.pl/wss/service/img/guest/TOPO/MapServer/WMSServer"
          [params]="{ LAYERS: 'Raster', FORMAT: 'image/jpeg' }"
          attributions="Topographic map © GUGiK"
        />
      </aol-layer-tile>
    </aol-map>
  `,
})
export class Epsg4326 {}

Architecture and OpenLayers mechanics

Setting projection="EPSG:4326" on aol-view switches the map to OpenLayers’ built-in equirectangular WGS 84 CRS (where zoom 0 spans 360° across 256 pixels, making [zoom]="8" ~0.0055°/px or ~600 m N–S).

The tiled WMS inherits EPSG:4326 from the view—automatically formatting WMS 1.3.0 BBOX coordinates latitude-first and requesting opaque FORMAT: 'image/jpeg' tiles—while <aol-control-scaleline units="degrees" /> displays angular scale.

How it works

  • projection="EPSG:4326" configures aol-view in geographic degrees using OpenLayers’ built-in WGS 84 definition (no proj4 needed).
  • At [zoom]="8", resolution is ~0.0055° per pixel (~600 m north–south).
  • Tiled WMS inherits EPSG:4326 from the view so server-rendered tiles paint 1:1 without browser warping.
  • <aol-control-scaleline units="degrees" /> reports angular distance in degrees, arc-minutes or arc-seconds.

Pitfalls

  • OGC WMS 1.3.0 mandates latitude-before-longitude BBOX axis order for EPSG:4326 (which OpenLayers handles automatically); hand-concatenated longitude-first WMS 1.3.0 URLs fetch the wrong hemisphere.
  • Equirectangular EPSG:4326 plots 1° of longitude (~71 km in Kraków) at the same pixel width as 1° of latitude (~111 km), visually stretching Poland ~1.56× wider east-to-west.
  • OpenLayers defaults WMS requests to transparent image/png, which leaves open land background transparent on GUGiK’s topographic service—specify FORMAT: 'image/jpeg' for opaque basemap layers.

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.