Select to view content in your preferred language

Spatial reference issue with 2 layers and setting the map's initial extent.

787
3
10-31-2011 10:19 AM
GarethMann
Deactivated User
I am trying to put two layers in the map. One layer is my own data served from our ArcGIS Server instance, the other one is the ESRI world street basemap layer. The two layers overlay on top of each other perfect (i.e. my data appears over the street map exactly where it is supposed to):
http://www.northmiamicra.org/testjsapi.html

However, when I try to set the initial extent of the map to be the initial extent of my own data (North Miami, Florida), it does zoom to the initial extent of my data, but for some reason it overlays it with the World Street Map in Nigeria! Why is this happening?
http://www.northmiamicra.org/test2layers.html

FYI, the code in the second link is virtually identical to the sample code found here:
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/map/map_setextent.html

The only thing I changed in the sample code was that I removed the geographicToWebMercator function because my data is already in Transverse Mercator.
0 Kudos
3 Replies
HemingZhu
Frequent Contributor
I am trying to put two layers in the map. One layer is my own data served from our ArcGIS Server instance, the other one is the ESRI world street basemap layer. The two layers overlay on top of each other perfect (i.e. my data appears over the street map exactly where it is supposed to):
http://www.northmiamicra.org/testjsapi.html

However, when I try to set the initial extent of the map to be the initial extent of my own data (North Miami, Florida), it does zoom to the initial extent of my data, but for some reason it overlays it with the World Street Map in Nigeria! Why is this happening?
http://www.northmiamicra.org/test2layers.html

FYI, the code in the second link is virtually identical to the sample code found here:
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/map/map_setextent.html

The only thing I changed in the sample code was that I removed the geographicToWebMercator function because my data is already in Transverse Mercator.


Transverse Mercator and WebMercator are two different projections. So the initial extent of your data would not be in WebMercator units. You could either change SR of your .mxd data frame to WebMercator, or do somekind of transformation of your initial extent (GeometryService.project, hard code your initial extent in WebMercator units etc).
0 Kudos
GarethMann
Deactivated User
Thanks for the reply hzhu,

I think what you mean is that the reason the two layers do not overlay on top of each other correctly is that they are on different projection systems. (My data is on Transverse Mercator (actually it is UTM, but for some reason ESRI has always called UTM simply Transverse Mercator) and the data in the Service is on "Web Mercator"). But if this is the case then it brings up two questions:

1) Why do the two services overlay perfectly fine if I do not specify an extent (as in the first link I showed)?

2) Why do I need to have the two layers on the same projection system? ArcMap will reproject data on the fly if they are on different projection systems. Evidently from the examples I have posted so does ArcGIS Server but it does not work when a new extent is specified?
0 Kudos
HemingZhu
Frequent Contributor
Thanks for the reply hzhu,

I think what you mean is that the reason the two layers do not overlay on top of each other correctly is that they are on different projection systems. (My data is on Transverse Mercator (actually it is UTM, but for some reason ESRI has always called UTM simply Transverse Mercator) and the data in the Service is on "Web Mercator"). But if this is the case then it brings up two questions:

1) Why do the two services overlay perfectly fine if I do not specify an extent (as in the first link I showed)?

2) Why do I need to have the two layers on the same projection system? ArcMap will reproject data on the fly if they are on different projection systems. Evidently from the examples I have posted so does ArcGIS Server but it does not work when a new extent is specified?


For your first question: JS API did transformation automatically for you just like arcmap did for layers with different extent. For your second question: You don't need to have your data on the same as ESRI base maps, but if you want to use the initial extent of your data which is not in WebMercator then problem will rise because the extent will have wrong value. That is why i said you could change data frame to WebMercator to get the right extent( write down these numbers, hard code in your app, and then reset your data frame back to your SR -if you like).
0 Kudos