Click event on map to open popup for a single layer arcGIS 4.16

797 views Asked by At

I have a list of layers in my arcGIS map and required to add popup when clicking on a specific layer. Is it possible to detect the required layer from the list of layers and open popup? When I applied the sample code given in the documentation, some times the popup is suddently disappearing. I believe it is because of the multiple layers on the map. How can we achieve it?

view.on("click", function(event){
  view.popup.open({
   location: event.mapPoint,  // location of the click on the view
   title: "You clicked here",  // title displayed in the popup
   content: "This is a point of interest"  // content displayed in the popup
  });
});

I am looping the layers and adding it to the map eg:'map.add(layer[count])'. I don't require the default popup as I have to get data from an API and populate in the popup template.

0

There are 0 answers