Enabling Wrap Around

The world is round. It does not end at the dateline. However, most flat representations of the earth only extend up till 180 East and West longitude. This makes it difficult to visualize areas that span across the date line, or routes that traverse the Pacific Ocean.

Starting from version 1.8 of the API, it is possible to visualize a world map extending seamlessly beyond the date line. Simply by enabling the wrapAround property on a map, the eastern and western hemispheres wrap around each other forming a continuous map and giving the impression that the map is endless. Panning a map becomes similar to spinning a globe.

Wrap Around

//enable wrap around
self.mapView.wrapAround = YES;

Constraints

The following following requirements must be satisfied before enabling wrap around :

1. The map's full envelope must cover the entire world.

2. The map's spatial reference must either be WGS 84 (WKID=4326) or Web Mercator (WKID=102113, 102100, or 3857). This means that all tiled layers in the map must belong to one of these spatial references. Dynamic layers, on the other hand, can be in any spatial reference because they are capable of reprojecting their data.

3. Dynamic layers must be based on map services from ArcGIS Server 10.0 or higher. This is because earlier versions of REST API do not support Well-Known Text (WKT) values for spatial reference, which is required for making dynamic map services support wrap around.

Normalizing geometries

To better understand wrap around, it is helpful to visualize a map as being composed of frames. The portion of a map between -180 longitude and +180 longitude is "frame 0". This frame is regularly visible even when wrap around is not enabled. Adjacent to this frame on the West is "frame 1" which extends hypothetically between +180 and +540 longitude. Adjacent to "frame 0" on the East is "frame -1" which extends hypothetically between -180 and -540 longitude.

Thus, depending upon which frame is being displayed, longitude values reported by a map may be real (within -180 and +180) or hypothetical (extend beyond -180 or +180). Here are some examples of geometries which may contain hypothetical coordinates -

When geometries contain hypothetical coordinates, you must first normalize them before you can use them to perform spatial queries or store them in a geodatabase. It is difficult to programmatically check at run-time if geometries need to be normalized or not. Thus, it is safer to always normalize geometries when wrap around is enabled.

You can normalize geometries using the normalizeCentralMeridianOfGeometry: method on AGSGeometryEngine.

5/9/2012