Tile and image services · Angular, React and OpenLayers
MapServer WMS images in degrees
Query a MapServer WMS 1.3.0 directly in geographic EPSG:4326 degrees with latitude-first axis order and HiDPI MAP_RESOLUTION in Angular.

What this example shows
Centred on Kraków across Central Europe at zoom 6 in a pure geographic degree view (EPSG:4326), the MapServer demo WMS composites NASA Blue Marble imagery, country borders and major population centres into one crisp HiDPI image.
When you need it
Global scientific portals, meteorological viewers and INSPIRE services frequently operate natively in geographic EPSG:4326 degrees rather than Spherical Mercator.
Running both the OpenLayers view and the WMS GetMap loader in EPSG:4326 avoids client-side raster warping completely while respecting OGC WMS 1.3.0 axis-ordering rules.
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.
mapserver-wms.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import {
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
MapComponent,
SourceImageComponent,
ViewComponent,
} from 'cc-openlayers';
import { createLoader } from 'ol/source/wms';
/**
* A single-image WMS of MapServer's demo: Blue Marble, country borders and cities around Kraków, asked for in
* geographic coordinates as WMS 1.3.0 images, at twice the pixels on a high-density screen.
*/
@Component({
selector: 'app-mapserver-wms',
imports: [
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
MapComponent,
SourceImageComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-view projection="EPSG:4326" [center]="[19.9373, 50.0617]" [zoom]="6" />
<aol-layer-image>
<aol-source-image [loader]="loader" attributions="MapServer demo: NASA Blue Marble" />
</aol-layer-image>
</aol-map>
`,
})
export class MapserverWms {
protected readonly loader = createLoader({
url: 'https://demo.mapserver.org/cgi-bin/wms?',
params: {
LAYERS: ['bluemarble,country_bounds,cities'],
VERSION: '1.3.0',
FORMAT: 'image/png',
},
projection: 'EPSG:4326',
// serverType only needs to be set when hidpi is true.
hidpi: true,
serverType: 'mapserver',
});
} 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.
mapserver-wms.react.tsximport { DefaultControls, DefaultInteractions, ImageLayer, ImageSource, Map, View } from 'cc-openlayers/react';
import { createLoader } from 'ol/source/wms.js';
const loader = createLoader({
url: 'https://demo.mapserver.org/cgi-bin/wms?',
params: {
LAYERS: ['bluemarble,country_bounds,cities'],
VERSION: '1.3.0',
FORMAT: 'image/png',
},
projection: 'EPSG:4326',
// serverType only needs to be set when hidpi is true.
hidpi: true,
serverType: 'mapserver',
});
const center = [19.9373, 50.0617];
/**
* A single-image WMS of MapServer's demo: Blue Marble, country borders and cities around Kraków, asked for in
* geographic coordinates as WMS 1.3.0 images, at twice the pixels on a high-density screen.
*/
export function MapserverWms() {
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View projection="EPSG:4326" center={center} zoom={6} />
<ImageLayer>
<ImageSource loader={loader} attributions="MapServer demo: NASA Blue Marble" />
</ImageLayer>
</Map>
);
}How the React version works
Blue Marble, borders and cities from MapServer's demo as WMS 1.3.0 images in EPSG:4326, at twice the pixels on dense screens.
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 loading function from createLoader (ol/source/wms) is created once.
From Angular to React
| Angular | React |
|---|---|
<aol-source-image [loader]> | <ImageSource loader={loader}> |
<aol-view projection="EPSG:4326" [center]> | <View projection="EPSG:4326" center={center} /> |
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
Both the map view’s projection and the WMS loader’s projection: 'EPSG:4326' run in WGS84 degrees. Under VERSION: '1.3.0', OGC mandates strict EPSG registry axis order—meaning BBOX is serialised as minLat,minLon,maxLat,maxLon, which OpenLayers handles automatically.
Enabling hidpi: true alongside serverType mapserver requests device-pixel dimensions and sets MAP_RESOLUTION (90 × pixelRatio), while comma-separated LAYERS composite bottom-to-top on the server.
How it works
- Matching
EPSG:4326across the viewprojectionand loaderprojection: 'EPSG:4326'eliminates client-side image reprojection. - With
VERSION: '1.3.0', OpenLayers formatsEPSG:4326BBOX parameters latitude-first as required by the OGC specification. hidpi: trueand serverType mapserver scale image dimensions and MAP_RESOLUTION for sharp Retina symbols and labels.- Comma-separated names in
LAYERScomposite three server layers into a single PNG from bottom to top.
Pitfalls
- WMS 1.1.1 used minLon,minLat,maxLon,maxLat for
EPSG:4326whereas WMS 1.3.0 flipped it to minLat,minLon,maxLat,maxLon—let OpenLayers build GetMap URLs rather than concatenating BBOX strings manually. - Confirm that the target projection appears in the service’s CRS / SRS capability list so client-side fallback reprojection is unnecessary.
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.