I need to capture the information of a popUp when I select a point on the map

757
2
Jump to solution
03-18-2022 08:32 AM
stiven
by
New Contributor III

When I select a point on the map, a popup window opens that shows information, but I need to capture that information that the popUp shows

Reading the documentation of arcgis javaScript I found this method, but it does not work for me to obtain the popUp data:

 

 

      view.on("click", function (event) {
    view.hitTest(event).then(function (response) {
      if (response.results.length) {
        let graphic = response.results.filter(function (result) {
          // check if the graphic belongs to the layer of interest
          return result.graphic.layer;
        })[0].graphic;

        // do something with the result graphic
        console.log(graphic.attributes);
      }
    });
  });

 

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

You don't need to listen to any events, you can watch for the popup.selectedFeature property to change

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeatur...

view.popup.watch("selectedFeature", (feature) => {
    // do something
})

View solution in original post

0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor

You don't need to listen to any events, you can watch for the popup.selectedFeature property to change

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeatur...

view.popup.watch("selectedFeature", (feature) => {
    // do something
})
0 Kudos
stiven
by
New Contributor III

Thanks for your help, it helped me

0 Kudos