Tile and image services · Angular, React and OpenLayers

WMS tiles across the 180th meridian

Wrap tiled WMS country borders seamlessly east and west across the 180th antimeridian on a multiWorld OpenLayers map at global zoom scales.

The world at zoom 1 nearly twice side by side, centred on Kraków's meridian, with the MapServer demo's country borders repeated over OpenStreetMap's land in each world.
A screenshot of the example. Country boundaries: MapServer's demonstration server (GatewayGeo). Map data © OpenStreetMap contributors.

What this example shows

Zoomed out to global level 1 where nearly two full copies of Earth fit side by side across a wide viewport, country borders from MapServer’s WMS repeat seamlessly across every copy of the continents east and west of the ±180° antimeridian.

When you need it

Trans-Pacific shipping trackers, global weather dashboards and aviation route planners pan continuously across the 180th meridian and zoom out to wide global overviews.

Although OGC WMS servers only understand coordinates within −180°..+180° (one canonical world), OpenLayers translates out-of-range wrapped tile requests back into canonical coordinates and paints them seamlessly in repeated world slots.

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.

wms-tiled-wrap-180.ts
import { ChangeDetectionStrategy, Component } from '@angular/core';
import {
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  LayerTileComponent,
  MapComponent,
  SourceOsmComponent,
  SourceTileWMSComponent,
  ViewComponent,
} from 'cc-openlayers';

/**
 * The world's country borders as tiles of a WMS over OpenStreetMap: OpenLayers reuses the tiles across the 180°
 * meridian, so the borders repeat with the world; `wrapX` set to false would draw them once. `multiWorld` lets the
 * view zoom out beyond one world, so that the repeats show side by side.
 */
@Component({
  selector: 'app-wms-tiled-wrap-180',
  imports: [
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerTileComponent,
    MapComponent,
    SourceOsmComponent,
    SourceTileWMSComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px">
      <aol-interaction-default />
      <aol-control-defaults />
      <aol-view [zoom]="1" [multiWorld]="true">
        <aol-coordinate [x]="19.9373" [y]="0" srid="EPSG:4326" />
      </aol-view>
      <aol-layer-tile><aol-source-osm /></aol-layer-tile>
      <aol-layer-tile>
        <aol-source-tilewms
          url="https://demo.mapserver.org/cgi-bin/wms"
          [params]="params"
          serverType="mapserver"
          attributions="Country borders: MapServer demo"
        />
      </aol-layer-tile>
    </aol-map>
  `,
})
export class WmsTiledWrap180 {
  protected readonly params = { LAYERS: 'country_bounds', TILED: true };
}

Architecture and OpenLayers mechanics

aol-source-tilewms enables horizontal world wrapping (wrapX: true) by default on projections with a known global extent such as Web Mercator—mapping any tile east of +180° or west of −180° to its canonical counterpart before querying country_bounds with serverType="mapserver".

Setting [multiWorld] to true on aol-view removes OpenLayers’ single-world zoom-out stop so zoom 1 can display repeated worlds side by side.

How it works

  • aol-source-tilewms wraps requests across the ±180° antimeridian automatically by mapping repeated tiles back into the canonical world.
  • Enabling [multiWorld] on the view lets wide screens zoom out past a single 360° span and pan endlessly east or west.
  • params selects country_bounds while serverType="mapserver" scales tile rendering to screen pixel density.

Pitfalls

  • Setting wrapX to false restricts WMS drawing to a single −180°..+180° band, leaving repeated OpenStreetMap continents on either side bare without borders.
  • Horizontal wrapping works only on projections OpenLayers recognises as global (canWrapX()); national planar grids (EPSG:2180, EPSG:27700) never wrap horizontally.
  • Without multiWorld on the view, OpenLayers clamps zoom-out so one world fills the viewport width (turning requested zoom 1 on a 958 px map into ~zoom 1.9).

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.