How can I access the coordinates from esri_mapping_popupToolContextMenu

234
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?

-------------------------
“GIS is a form of digital mapping technology. Kind of like Google Earth, but better.” ~ Arnold Schwarzenegger
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
SeanJones
Esri Regular Contributor

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
SeanJones
Esri Regular Contributor

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