Is there a way to project the coordinates without using geometry service?

3728
10
06-20-2011 02:55 PM
DanDong
New Contributor
Hi guys,

I am using mouse_move event to show the coordinates of the position. Just like this sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MouseCoords

But the projection of the maps in the map service is Transverse_Mercator and I want to display the coordinates in lat/long. I know geometry service supports projection task and I tied this method in my codes. But since we all move mouse very quickly and frequently and every move needs projection, this method really slows down the response time...

I really would like to know whether there is a api or method to do this without projection every mousemove point nor kill the performance. Any thoughts or clues? Thank you!!

Below are my codes:
private void MyMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs args)
        {
            if (MyMap.Extent != null)
            {
                System.Windows.Point screenPoint = args.GetPosition(MyMap);
                ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = MyMap.ScreenToMap(screenPoint);
                //MapCoordsTextBlock.Text = string.Format("Map Coords: X = {0}, Y = {1}",
                    //Math.Round(mapPoint.X, 4), Math.Round(mapPoint.Y, 4));

                //MapPoint inputMapPoint = new MapPoint(x, y, new SpatialReference(4326));

                //use geometryservice's project utility
                //GeometryService geometryService = new GeometryService("http://rmms-dev.atlas.illinois.edu/ArcGIS/rest/services/Geometry/GeometryServer");
                //geometryService.ProjectCompleted += MouseCoordinate_geometryService_ProjectCompleted;
                //geometryService.Failed += GeometryService_Failed;
                //geometryService.ProjectAsync(new List<Graphic>() { new Graphic() { Geometry = mapPoint } }, new SpatialReference(4326), mapPoint);
            }
        }

void MouseCoordinate_geometryService_ProjectCompleted(object sender, GraphicsEventArgs e)
        {
            Graphic resultGraphic = e.Results[0];
            MapPoint resultMapPoint = resultGraphic.Geometry as MapPoint;
            MapCoordsTextBlock.Text = string.Format("Map Coords: X = {0}, Y = {1}",
                    Math.Round(resultMapPoint.X, 4), Math.Round(resultMapPoint.Y, 4));
        }
0 Kudos
10 Replies
DanDong
New Contributor
Hey Doc, I really really want to try this sample code. But I still cannot add the ProNet.dll to the reference...(I can only add it from XX.Web --Reference--Add reference) I assume you must successfully added it. Could you share your ProNet.dll file? I am going to give another shot to add it. Thanks a lot! 🙂 My email is shirleydd@gmail.com
0 Kudos