English

How To: Convert a screen coordinate to a WGS84 value using the ArcGIS Mobile SDK

Summary

Mobile Map Control mouse events such as MouseMove, MouseDown, and MouseUp provide a MapMouseEventArgs object. The MapMouseEventArgs object provides the user with direct access to both the screen x and y units and their corresponding map coordinates.

Instructions provided describe how to convert a screen coordinate to a WGS84 value using the ArcGIS Mobile SDK.

Procedure

To convert the screen coordinate to a ServerCoordinate, use the ToWgs1984 method on the SpatialReference object to get a WGS84 value.

Code:
//C# Code sample
ServerCoordinate svrCoord = map1.MapCache.SpatialReference.MobileToServerGeometry(e.MapCoordinate);

ServerCoordinate[] svrCoords = new ServerCoordinate[] {svrCoord};

svrCoords = map1.MapCache.SpatialReference.ToWgs1984(svrCoords);

System.Console.WriteLine("Lat: {0}; Lon: {1}", svrCoords[0].Y, svrCoords[0].X);