I have an ArcGIS Server JavaScript API v4 map containing some feature layers which each have a popupTemplate defined, so clicking on the layer(s) automatically shows the layers' popup.

I need to disable the popups temporarily, so that clicking on the map does something else, but does not show the popup. Then, after my operation is over, I want to restore all of the feature layer popups.

Is there an easy way to accomplish this? Some of the default widgets exhibit this behaviour, as in this example with the Sketch Widget:


Note that while the widget is idle, clicking on the map shows the layer popups, but when the widget is active the popups do not display. When the widget is no longer active, the popups are restored.

How can I achieve the same outcome? See the rough mockup in the code:

  • the first time the user clicks on the map, show the console message and don't display the popup
  • when the listener is disabled, revert to showing the layer popups
clickListener = view.on("click", (event) => {
  console.log("disable layer popup while listener is active, allow while inactive")

1 Answer 1


The answer I came up with is to watch the view's popup, and close it where necessary:

view.popup.watch("visible", (visible) => {
  if (visible){
    view.popup.visible = condition_goes_here;

Using this approach the popup is not shown when clicking on the feature layer when the condition is met. Otherwise, the popup shows as usual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.