Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have an app that does some buffering, only problem is when I click on the map to put in the point/line/polygon vertices to do the buffer, I get popups at every mouseclick. It doesn't interrupt the buffer process but its super annoying.

At first thought I wanted to try and disable the popups so that they didn't show when "No information available" was the result. But I figure there will be more times than not when a popup will return some results and thus, need to disable/hide the popup so that it doesn't appear at all while the buffer process is running.

I've tried putting map.infoWindow.hide(); within the buffer without success and also saw this post recommending an onClick handler and have been unsuccessful as well. Any tips appreciated.

share|improve this question

2 Answers 2

Look at this post for a good example JS API Toggle Pop-Up On & Off. When you add connect to the onclick event to the map or featurelayer etc, you need to save the reference to the clickHandle. Then when a workflow is started where you don't want popups on, you disconnect and then re-connect when finished.

//instead of this -- don't do this
dojo.connect(featureLayer,"onClick",function(evt){
   map.infoWindow.setFeatures([evt.graphic]);
   map.infoWindow.show(evt.mapPoint);
});

//do this -- save the click handle to disconnect or reconnect later
var clickHandlePopup = dojo.connect(featureLayer,"onClick", showPopup(evt));

//clickhandler
function showPopup(evt){
   map.infoWindow.setFeatures([evt.graphic]);
   map.infoWindow.show(evt.mapPoint);
}

//start buffering -- disconnect
if (clickHandlePopup) {
    dojo.disconnect(clickHandlePopup);
    clickHandlePopup = null;
}

//stop buffering -- connect
if (!clickHandlePopup) {
    clickHandlePopup = dojo.connect(featureLayer, "onClick", showPopup(evt));
}

Also, see this post for turning popups on and off when using webmaps Turn Popups On/Off in ArcGIS Online Webmap via Javascript API Web Application

share|improve this answer

This question is a year old but this alternate solution may be helpful to others.

If you are using the Popup class you can set the Popup to a global variable so that you can set it not to show the window while updating. To prevent getting the "No information available" window, just set visibleWhenEmpty to false and hideDelay to 0:

var popup = new Popup(...);
popup.visibleWhenEmpty= false;
popup.hideDelay = 0;        // Number of milliseconds after which the popup window will be hidden when visibleWhenEmpty is false & number of features is 0

map = new Map("...", {
    ...
    infoWindow: popup
});

map.on("update-start", function () {
    popup.popupWindow= false;        // Indicates whether the popup window should be displayed.
}

map.on("update-end", function () {
    popup.popupWindow= true;        // Indicates whether the popup window should be displayed.
}

Unfortunately, this does not prevent the "Searching" window from popping up so you'll still briefly get a popup window even if there are no results. It may actually be preferable to get the "No information available" window for a few seconds instead of not seeing it at all.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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