Solved! Go to Solution.
private ESRI.ArcGIS.Client.Tasks.GeometryService _geometryService = new ESRI.ArcGIS.Client.Tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); private ESRI.ArcGIS.Client.Geometry.MapPoint ConvertToWgsCoordinates(ESRI.ArcGIS.Client.Geometry.MapPoint point) { ESRI.ArcGIS.Client.Geometry.MapPoint result = null; System.Collections.Generic.IList<Graphic> graphics = this._geometryService.Project(new System.Collections.Generic.List<Graphic>() { new Graphic() { Geometry = point } }, new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326)); result = graphics[0].Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint; } return result; }
See here:
http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?esri.arcgis.client~esri.arcgis.cli...
That seems to assume that I have a WebMercator source coordinate system. I want to project any coordinate system to WGS1984. Is this possible?
Trying WebMercator.ToGeographic throws an exception: "Invalid spatial reference." I guess because my source spatial reference is NOT Web Mercator.
Any other ideas?
private ESRI.ArcGIS.Client.Tasks.GeometryService _geometryService = new ESRI.ArcGIS.Client.Tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); private ESRI.ArcGIS.Client.Geometry.MapPoint ConvertToWgsCoordinates(ESRI.ArcGIS.Client.Geometry.MapPoint point) { ESRI.ArcGIS.Client.Geometry.MapPoint result = null; System.Collections.Generic.IList<Graphic> graphics = this._geometryService.Project(new System.Collections.Generic.List<Graphic>() { new Graphic() { Geometry = point } }, new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326)); result = graphics[0].Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint; } return result; }
I was able to do something similar using the following code.private ESRI.ArcGIS.Client.Tasks.GeometryService _geometryService = new ESRI.ArcGIS.Client.Tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); private ESRI.ArcGIS.Client.Geometry.MapPoint ConvertToWgsCoordinates(ESRI.ArcGIS.Client.Geometry.MapPoint point) { ESRI.ArcGIS.Client.Geometry.MapPoint result = null; System.Collections.Generic.IList<Graphic> graphics = this._geometryService.Project(new System.Collections.Generic.List<Graphic>() { new Graphic() { Geometry = point } }, new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326)); result = graphics[0].Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint; } return result; }
I'm converting to GCS_WGS_1984 to display coordinates on mouse over. You would have to replace 4326 with the WKID for what you're converting to.
The main issue that I have with this is that it is using an online service which I won't always have access to. I'm trying to find a way to do this locally if possible.