How can I access the coordinates from esri_mapping_popupToolContextMenu

551
1
Jump to solution
10-24-2019 04:21 AM
TomGeo
by
Occasional Contributor III

The 'esri_mapping_popupToolContextMenu' has a couple of items in it that access the map coordinates from the click event calling the context menu. Since I have my own button/item in the 'esri_mapping_popupToolContextMenu' I would like to access these coordinates to use them in the OnClick method of my button.

How can I get these coordinates?

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Thomas,

You can use FrameworkApplication.ContextMenuDataContext to cast to a windows point then make a mappoint out of it in your buttons click method.

    protected override void OnClick()
    {
      //get the screen location of the right click
      var cmdc = (System.Windows.Point)FrameworkApplication.ContextMenuDataContext;

      QueuedTask.Run(async() =>
        {
          var mapPoint = MapView.Active.ScreenToMap(cmdc);
          
          //create search polygon at 5 pixels
          var searchPoly = CreateSearchPolygon(mapPoint, 5);

          //find features under the search geometry
          var searchFeatures = MapView.Active.GetFeatures(searchPoly);‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The full sample can be found here: Replace Sketch

View solution in original post

1 Reply
by Anonymous User
Not applicable

Thomas,

You can use FrameworkApplication.ContextMenuDataContext to cast to a windows point then make a mappoint out of it in your buttons click method.

    protected override void OnClick()
    {
      //get the screen location of the right click
      var cmdc = (System.Windows.Point)FrameworkApplication.ContextMenuDataContext;

      QueuedTask.Run(async() =>
        {
          var mapPoint = MapView.Active.ScreenToMap(cmdc);
          
          //create search polygon at 5 pixels
          var searchPoly = CreateSearchPolygon(mapPoint, 5);

          //find features under the search geometry
          var searchFeatures = MapView.Active.GetFeatures(searchPoly);‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The full sample can be found here: Replace Sketch