[GIS] ArcGIS javascript api: Convert a map service with projected coords to web mercator

arcgis-javascript-apicoordinate systemweb-mapping

here I see a question about tiled map services. But what about dealing with an arcgis server map service in a projected coordinate system like say 2278, how would I convert this to web mercator so that it will fall correctly in my map?

What are the choices using dynamic layer or other?

I don't have any control over the map service. Thanks.

Best Answer

If the map service you're using is a dynamic map service, create an ArcGISDynamicMapServiceLayer and add it to your map that already has one or more tiled web mercator services. Because dynamic map services can be projected on the fly, the ArcGIS API for JavaScript will construct an exportMap request where the resulting map image is in web mercator. You do not need to worry about building the request to exportMap– the API does this for you. The general workflow is as follows:

  • create your map (with or without an extent, if you specify an extent, it needs to be in web mercator if you're using tiled services in web mercator)
  • add a tiled web meractor service using ArcGISTiledMapServiceLayer
  • add your dynamic map service using ArcGISDynamicMapServiceLayer

If your map service that has a spatial reference of 2278 is tiled, you cannot overlay it on web mercator tiled services because tiled services cannot be reprojected on the fly.

One general takeaway from this is that your map's spatial reference has to match that of your tiled services. The map's spatial reference is defined by the spatial reference of the extent you pass to the map constructor, or the first layer that is added to the map.