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.

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.tsimport { 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 {} 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.
reprojection-wgs84.react.tsximport { Coordinate, DefaultControls, DefaultInteractions, Map, OSMSource, TileLayer, View } from 'cc-openlayers/react';
/** OpenStreetMap tiles reprojected in the browser to a view in WGS84. */
export function ReprojectionWgs84() {
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View projection="EPSG:4326" zoom={6}>
<Coordinate x={19.9368} y={50.0614} srid="EPSG:4326" />
</View>
<TileLayer>
<OSMSource />
</TileLayer>
</Map>
);
}How the React version works
OpenStreetMap's Web Mercator tiles reprojected in the browser into a view in EPSG:4326 over Poland; only the view's projection changes.
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. The example has no shared file.
From Angular to React
| Angular | React |
|---|---|
<aol-view projection="EPSG:4326" [zoom]="6"> | <View projection="EPSG:4326" zoom={6}> |
<aol-source-osm /> | <OSMSource /> |
<aol-coordinate [x] [y] srid="EPSG:4326" /> inside the view | <Coordinate x y srid="EPSG:4326" /> inside View |
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
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"onaol-viewtriggers automatic client-side tile warping whileaol-source-osmremains 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:4326view 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:4326compresses vertical height to ~64% at 50° N—visibly flattening baked-in street and city labels compared with nativeEPSG:4326WMS rendering.
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.