UHarano-esristaff

How do you get the map coordinates of a tool's click location

Discussion created by UHarano-esristaff Employee on Mar 24, 2016
Latest reply on Dec 27, 2016 by wkaiser-esristaff

This question was posted recently by Ted Chapin  @Ted"How do you get the map coordinates of a tool's click location?"

 

Here is a code snippet to do this:

 

protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)

       {

           if (e.ChangedButton == MouseButton.Left)

               e.Handled = true;//Let Framework know we want to handle MouseDown asynchronously

        }

        private MapPoint _lastClickedMapPoint = null;

        protected override async Task HandleKeyDownAsync(MapViewKeyEventArgs k)

       {

           _lastClickedMapPoint = await QueuedTask.Run(() => ActiveMapView.ClientToMap(k.ClientPoint));

           //TODO - do something with _lastClickedMapPoint

       }

 

Thanks

Uma Harano

ArcGIS Desktop SDK Team 

Outcomes