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.

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.tsimport { 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 };
} 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.
wms-tiled-wrap-180.react.tsximport {
Coordinate,
DefaultControls,
DefaultInteractions,
Map,
OSMSource,
TileLayer,
TileWMSSource,
View,
} from 'cc-openlayers/react';
const params = { LAYERS: 'country_bounds', TILED: true };
/**
* 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.
*/
export function WmsTiledWrap180() {
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View zoom={1} multiWorld={true}>
<Coordinate x={19.9373} y={0} srid="EPSG:4326" />
</View>
<TileLayer>
<OSMSource />
</TileLayer>
<TileLayer>
<TileWMSSource
url="https://demo.mapserver.org/cgi-bin/wms"
params={params}
serverType="mapserver"
attributions="Country borders: MapServer demo"
/>
</TileLayer>
</Map>
);
}How the React version works
Country borders from a WMS repeat with each world, and multiWorld lets the view zoom out beyond one world.
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.
From Angular to React
| Angular | React |
|---|---|
<aol-view [multiWorld]="true"> | <View multiWorld> |
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
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. paramsselectscountry_boundswhileserverType="mapserver"scales tile rendering to screen pixel density.
Pitfalls
- Setting
wrapXtofalserestricts 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
multiWorldon 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).
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.