I'm converting some code from ArcObjects to ArcPro. The following bit of code is working. It converts a point clicked on by the user, to decimal degrees, but I'm sure there is a smoother way to do this.
var mousePoint = MapView.Active.ClientToMap(e.ClientPoint);
ToGeoCoordinateParameter ddParam = new ToGeoCoordinateParameter(GeoCoordinateType.DD);
string geoString = mousePoint.ToGeoCoordinateString(ddParam);
string mapPoint = geoString.Split(' ');
mapPoint = mapPoint.Remove(mapPoint.Length - 1); //the N
mapPoint = "-" + mapPoint.Remove(mapPoint.Length - 1); //the W; use the '-' to change it from Easting
What would the proper way be to take mousePoint and convert/transform it to DD.
So I guess I am answering my own question, but by scouring through more of the SDK samples on GitHub, I came up with this:
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
var coord = GeometryEngine.Instance.Project(geometry, SpatialReferences.WGS84) as MapPoint;
if (coord != null)
lng = coord.X;
lat = coord.Y;
<more code here..................................>
Previously I was using the HandleMouseDown event, but this event gives me the Geometry of the click, which is exactly what I was looking for. Then I just have to Project it. Much simpler than my first attempt.
Hopefully this helps someone else.
You probably noticed by now that there are some significant differences between ArcObjects and the ArcGIS Pro SDK. If you are new to the ArcGIS Pro SDK I would recommend to look at some the 'ProConcept' documents we provide on our documentation wiki: https://github.com/Esri/arcgis-pro-sdk/wiki . Needless to say samples are always helpful (which you already discovered) and so are our ProSnippets which are in essence small copy/paste ready snippets that perform a specific task. In case you haven't tried this there are quite a few technical sessions on YouTube, you can find them searching for "arcgis pro sdk for .net".