[GIS] Changing basemaps with different spatial references (ArcGIS Javascript)

arcgis-javascript-apiarcgis-online-basemaps

I've got a new requirement to switch basemaps that have different spatial references. The app is using ArcGIS Javascript, and switching to Silverlight is not an option at this point in development. I saw this question from 2 years ago and was hoping there was an alternative. Is there an easier way to change basemaps that have different spatial references in 3.6?

Best Answer

The basemap defines the spatial reference of the map; changing the basemap and its spatial reference could cause unintended issues. Some possible alternatives are:

  1. Destroy and recreate the map with the new basemap and load any other layers. You would want to be sure you destroy all handlers and other objects before recreating the map to avoid memory leaks.

  2. Create a new map with the new basemap. If you want to switch back and forth, keep the old map; otherwise destroy it.

  3. Insert the new basemap as a layer just above the basemap in the display order. The new layer would be warped to the map's spatial reference, which might slow down your map and look kinda crappy depending on the layer's contents.