1

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.

Adam-KER
  • 67
  • 9
  • You need to use the ```hitTest()``` method to find something on a specific layer https://developers.arcgis.com/javascript/latest/sample-code/view-hittest/index.html – nll_ptr Oct 08 '20 at 18:27
  • 1
    Thanks for the response. The hitTest() will work. In my case I have considered the layer separately and added the property 'popupTemplate: popupTrailheads'. In the 'popupTrailheads' variable added popup template properties such as title and content. – Adam-KER Oct 09 '20 at 13:02

0 Answers0