Posts Tagged ‘ArcGIS Server’

Wrap data around 180 longitude with ArcGIS Server and JavaScript API

What I wanted to do

I have data extends across 180 longitude. When I build a web map out of the data, I want it to be wrapped around 180 so that I can pan the map across 180. To achieve that, according to samples in ArcGIS JavaScript API 2.3, I need dynamic map service published by ArcGIS Server 10 and add “wrapAround180:true” to the options of esri.Map.

What I have

  • Shapefile
  • ArcGIS 10
  • ArcGIS Server 10


First of all, what is dynamic map service? My understanding of dynamic map service after reading Publish Map Service in ArcGIS 10 Desktop Help is that as long as the map service is not cached, it is dynamic map service. So I followed the steps listed in the help to publish my data as a map service with WMS, with caching set to “Draw this map service dynamically” in the service setting in ArcGIS Server. Then in the web map that I built with ArcGIS JavaScript API, I set the map to wrap around 180 (var map = new esri.Map(“MyMapID”, {wrapAround180:true})) and created a layer consuming the WMS (var wmsLayer = new esri.layers.WMSLayer(“the WMS layer”)).

It didn’t work. The map was still cut off at 180.

After some internet research, I found out that to make the wrap around 180 work, I need to create a ArcGISDynamicMapServiceLayer and the layer has to consume a REST service. So now the question became how to create a REST service.  According to ArcGIS Server REST API, to find out the REST services on my ArcGIS Server, I used http://<host&gt;:8399/arcgis/rest. My data was not there, even through I have published my data as map service. After talking to someone who have experience with REST service, I found out that the problem is related to REST service caching. On my ArcGIS Server, the caching has to be cleared manually, which is why my data didn’t show up in the REST service directory. To manage the REST service, I used http://<host>:8399/arcgis/rest/admin. Once the cache is cleared manually, my data showed up.

Now, instead of a WMS layer, I create a dynamic map service layer in my web map (var restLayer = new esri.layers.ArcGISDynamicMapServiceLayer(“http://<host&gt;:8399/arcgis/rest/services/MyData”)) and guess what, my data goes across 180 now!