HOW TO
Mobile ADF is manipulating its geometry, including coordinates, using integer value types. As a programmer, it may be necessary to frequently convert real-world coordinates, expressed in double coordinates, into integer coordinates. For instance, a Web Service may return a geocoded position to plot on the map. If the double coordinates are based on the Map Spatial Reference or on WGS84, convert them into integer map coordinates using the SpatialReference class.
This class is accessible from the MapCache class and allows transformation from double to integer for a given projection. It also allows transformation of Lat/Long into double or integer coordinates.
For example:
Code:
ServerCoordinate svrCoord = new ServerCoordinate(-117.234, 34.0453);
ServerCoordinate[] svrCoords = new ServerCoordinate[] { svrCoord };
CoordinateCollection coordCollection = map1.MapCache.SpatialReference.Wgs84ToMobileCoordinate(svrCoords);
map1.FlashGeometry(Pens.Black, new SolidBrush(Color.Red), 4, 3, coordCollection[0]);
Code:
private void map1_MouseMove(object sender, ESRI.ArcGIS.Mobile.MapMouseEventArgs e)
{
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);
}
Get help from ArcGIS experts
Download the Esri Support App