How to get Latitude Longitude

11-07-2014 09:50 PM
New Contributor

I have a right click menu at one of maps feature layer. when use clicks on 1 menu item he should be able to open google map with same cordinates

Like this url

Google Maps

so I have the code like this in this menu Item command:

private void OnGoogleMapOpen(object param)


            var e = param as GraphicMouseButtonEventArgs;

            MapPoint clickpoint = HpmMap.ScreenToMap(e.GetPosition(HpmMap));

            double X = clickpoint.X;

            double Y = clickpoint.Y;

            var mercator = new WebMercator();


            new Uri(""+X.ToString()+","+Y.ToString(), UriKind.Absolute),



I see x and y are not Lat/Long. How to get lat long for this graphic/ geometry.

0 Kudos
4 Replies
Occasional Contributor


This is what I use:

MapPoint mapPoint = Map.ScreenToMap(screenPoint);

Geometry.NormalizeCentralMeridian(mapPoint) as ESRI.ArcGIS.Client.Geometry.MapPoint;

var webMercator = new WebMercator();

var result = webMercator.ToGeographic(mapPoint) as MapPoint;


New Contributor

I m getting invalid Spatial Reference error.

System.ArgumentException was unhandled by user code

  Message=Invalid spatial reference.


       at ESRI.ArcGIS.Client.Projection.WebMercator.ToGeographic(Geometry proj)

       at Delasoft.Hpm.ViewModel.HpmBaseEsriMapViewModel.OnGoogleMapOpen(Object param)

       at Telerik.Windows.Controls.DelegateCommand.Execute(Object parameter)

       at Telerik.Windows.Controls.RadMenuItem.ExecuteCommand()

       at Telerik.Windows.Controls.RadMenuItem.OnClickImpl()

       at Telerik.Windows.Controls.RadMenuItem.OnClick()

       at Telerik.Windows.Controls.RadMenuItem.ClickItem()

       at Telerik.Windows.Controls.RadMenuItem.HandleMouseUp()

       at Telerik.Windows.Controls.RadMenuItem.OnMouseLeftButtonUp(MouseButtonEventArgs e)

       at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)

       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)


0 Kudos
Occasional Contributor

What coordinates are you getting back before you try to convert to lat long?  Are you sure that you are in web Mercator?

0 Kudos
Regular Contributor

If your map is not using the web mercator projection then you will need to use a geometry service to project your map click location to lat/lon coordinates. See the Project operation on the geometry task.

Check the map spatial reference to see what coordinate system you need to project from (details are at the bottom of the page).

0 Kudos