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.

Central Europe around Kraków at zoom 6 in geographic degrees: NASA's Blue Marble with the country borders, the cities of a million people or more in red and those of a quarter of a million or more in blue.
A screenshot of the example. Map images: MapServer's demonstration server (GatewayGeo), with NASA's Blue Marble, world country boundaries and cities.

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

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:4326 across the view projection and loader projection: 'EPSG:4326' eliminates client-side image reprojection.
  • With VERSION: '1.3.0', OpenLayers formats EPSG:4326 BBOX parameters latitude-first as required by the OGC specification.
  • hidpi: true and serverType mapserver scale image dimensions and MAP_RESOLUTION for sharp Retina symbols and labels.
  • Comma-separated names in LAYERS composite three server layers into a single PNG from bottom to top.

Pitfalls

  • WMS 1.1.1 used minLon,minLat,maxLon,maxLat for EPSG:4326 whereas 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.

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.