Projections · Angular, React and OpenLayers

OpenStreetMap reprojected to WGS 84

Reproject Web Mercator OpenStreetMap raster tiles into an EPSG:4326 geographic view in the browser using OpenLayers adaptive triangulation.

OpenStreetMap in degrees over Central Europe, from Kaliningrad and Gdańsk in the north to Zagreb and Cluj-Napoca in the south, with Poland in the upper half and its labels visibly flattened.
A screenshot of the example. Map data © OpenStreetMap contributors.

What this example shows

Across Central Europe from Gdańsk to Zagreb at [zoom]="6", standard Spherical Mercator (EPSG:3857) OpenStreetMap tiles warp dynamically in the browser to align seamlessly inside an equirectangular EPSG:4326 degree view—activated by changing solely the View’s projection attribute.

When you need it

Applications locked to EPSG:4326 by legacy WMS overlays, military grids or regulatory requirements often still want familiar OpenStreetMap or commercial XYZ street tiles underneath—even though XYZ providers publish exclusively in EPSG:3857.

OpenLayers’ built-in client-side raster reprojection warps any tile pyramid on the fly without standing up a server-side MapProxy or GDAL reprojection cache.

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.

reprojection-wgs84.ts
import { ChangeDetectionStrategy, Component } from '@angular/core';
import {
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  LayerTileComponent,
  MapComponent,
  SourceOsmComponent,
  ViewComponent,
} from 'cc-openlayers';

/** OpenStreetMap tiles reprojected in the browser to a view in WGS84. */
@Component({
  selector: 'app-reprojection-wgs84',
  imports: [
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerTileComponent,
    MapComponent,
    SourceOsmComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px">
      <aol-interaction-default />
      <aol-control-defaults />
      <aol-view projection="EPSG:4326" [zoom]="6">
        <aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
      </aol-view>
      <aol-layer-tile><aol-source-osm /></aol-layer-tile>
    </aol-map>
  `,
})
export class ReprojectionWgs84 {}

Architecture and OpenLayers mechanics

Setting projection="EPSG:4326" on aol-view (centred via srid="EPSG:4326") while leaving aol-source-osm in its native EPSG:3857 automatically activates OpenLayers’ raster reprojection pipeline.

For each destination EPSG:4326 tile, OpenLayers recursively subdivides the extent into a triangle mesh until projection error falls below 0.5 pixels, fetches matching-resolution EPSG:3857 source tiles, and renders piecewise affine-warped triangles onto a canvas tile.

How it works

  • Setting projection="EPSG:4326" on aol-view triggers automatic client-side tile warping while aol-source-osm remains in EPSG:3857.
  • Adaptive triangulation subdivides each target tile until piecewise affine error stays under half a pixel.
  • View zoom follows EPSG:4326 (360° / 256 px at zoom 0), placing [zoom]="6" at ~0.022° per pixel over Kraków (srid="EPSG:4326").

Pitfalls

  • Because Spherical Mercator clips at ±85.0511° latitude, zooming an EPSG:4326 view out to ±90° leaves thin unmapped polar strips above 85.05° N and below 85.05° S.
  • Warping pre-rendered EPSG:3857 PNGs into EPSG:4326 compresses vertical height to ~64% at 50° N—visibly flattening baked-in street and city labels compared with native EPSG:4326 WMS rendering.

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.