Select to view content in your preferred language

Convert coordinates

2092
2
12-12-2011 01:12 AM
DidarBultanov
Emerging Contributor
Hi all, sorry for my bad English, I'll try to explain:)
are the coordinates of the mouse(x,y), in meters, I want to display on the map, in meters and WGS (min,sec & degress)
tell me conversion algorithm
private void MyMap_MouseClick(object sender, Map.MouseEventArgs args)
        {
            if (IdentifyGrid.IsSelected)
            {
                MapPoint clickPoint = args.MapPoint;
                MapCoordsTextBlock.Text = string.Format("X = {0}, Y = {1}", Math.Round(clickPoint.X, 4), Math.Round(clickPoint.Y, 4));
......
0 Kudos
2 Replies
DeminHu
Deactivated User
Please see if the following code could help you a little or not

#region Map - mouse events
        private void HuntMap_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                if (HuntMap.Extent != null)
                {
                    System.Windows.Point screentPoint = e.GetPosition(HuntMap);
                    ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint = HuntMap.ScreenToMap(screentPoint);

                    if (HuntMap.WrapAroundIsActive && mapPoint != null)
                    {
                        mapPoint = ESRI.ArcGIS.Client.Geometry.Geometry.NormalizeCentralMeridian(mapPoint) as ESRI.ArcGIS.Client.Geometry.MapPoint;
                        CoordText.Text = string.Format("Web Mecator( X:Y )  : {0} : {1}", Math.Round(mapPoint.X, 0), Math.Round(mapPoint.Y, 0));
                        //   convert to latitude and longtitude
                        Graphic graphic = new Graphic();
                        graphic.Geometry = mapPoint;
                        List<Graphic> gList = new List<Graphic>();
                        graphic.Geometry.SpatialReference = HuntMap.SpatialReference;
                        gList.Add(graphic);

                        GeometryService projService = new GeometryService();
                        projService.Url = ConfigManager.GeometryServiceUrl;
                        projService.ProjectCompleted += new EventHandler<GraphicsEventArgs>(ConvertTolatLong_ProjectCompleted);
                        projService.ProjectAsync(gList, new SpatialReference(4326));
                    } //end  if (HuntMap.WrapAroundIsActive && mapPoint != null)
                } // end if
            } // end try
            catch (Exception error)
            {
                MessageBox.Show("HuntMap_MouseMove" + error.Message);
            }
        }
        //--------------------------------------------------
        void ConvertTolatLong_ProjectCompleted(object sender, GraphicsEventArgs args)
        {
            try
            {
                MapPoint pt = args.Results[0].Geometry as MapPoint;
                LatLongText.Text = "Latitude: Longtitude ( X:Y): " + string.Format("{0} : {1}", Math.Round(pt.X, 4), Math.Round(pt.Y, 4));
            }
            catch (Exception error) { }
        }
//---------------------------------------------------

Hi all, sorry for my bad English, I'll try to explain:)
are the coordinates of the mouse(x,y), in meters, I want to display on the map, in meters and WGS (min,sec & degress)
tell me conversion algorithm
private void MyMap_MouseClick(object sender, Map.MouseEventArgs args)
        {
            if (IdentifyGrid.IsSelected)
            {
                MapPoint clickPoint = args.MapPoint;
                MapCoordsTextBlock.Text = string.Format("X = {0}, Y = {1}", Math.Round(clickPoint.X, 4), Math.Round(clickPoint.Y, 4));
......
0 Kudos
DidarBultanov
Emerging Contributor
Please see if the following code could help you a little or not


//---------------------------------------------------


thanks, + http://kiwigis.blogspot.com/2009/05/convert-decimal-degrees-to-degrees.html
0 Kudos