Select to view content in your preferred language

Getting Longitude and Latitude

2624
3
04-09-2011 09:44 AM
MichaelAquilina
Emerging Contributor
Hi everyone, im new to using this ArcGIS tool and i was wondering how you could retreive longitude and latitude information by using screen coordinates (for example a user clicks somewhere and the longitude and latitude of that point are shown). I have tried using ScreenToMap() but it seems to be returning bad results for me (i think its returning the X and Y coordinates relative to the entire map). Any help would be appreciated. Thanks guys! 🙂
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
The 'Show Map Coordinates' sample (http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MouseCoords) is doing that.
Basically you have to call GetPosition to get the position relative to the map and then ScreenToMap to get the position in the map coordinates.

Additionaly if your map spatial reference is not geographic, you may have to convert to geographical coordinates.
0 Kudos
MichaelAquilina
Emerging Contributor
The 'Show Map Coordinates' sample (http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MouseCoords) is doing that.
Basically you have to call GetPosition to get the position relative to the map and then ScreenToMap to get the position in the map coordinates.

Additionaly if your map spatial reference is not geographic, you may have to convert to geographical coordinates.


Hi, thanks for your reply

I was aware of being able to convert screen coordinates to map coordinates, however i cant seem to figure out how to change those map coordinates to appropriate latitude and longitude values. Would this be what your referring to when talking about changing my spatial reference? How would i be able to do this?
0 Kudos
MichaelAquilina
Emerging Contributor
Ok i seem to have figured it out. The MapPoint class contains helper methods for changing back and forth between the Geographic and WebMercator Spatial References

Point.WebMercatorToGeographic();    //to longitude and latitude
Point.GeographicToWebMercator();    //to web mercator
0 Kudos