shirleydd

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

Discussion created by shirleydd on Jun 20, 2011
Latest reply on Jun 22, 2011 by shirleydd
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));
        }

Outcomes