But clicking on a graphic would then also constitute a click on the map
dojo.connect(map, "onClick", function(evt) { if(!evt.graphic) { console.log("map click"); } });
I tried setting a dojo.connect event handlers like dojo.connect(map, "onClick", map.infoWindow.hide()); but that doesn't seem to work.
dojo.connect(map, "onClick", function() { map.infoWindow.hide(); });
dojo.connect(map.infoWindow, "onShow", function() { dojo.connect(map, "onClick", function() { map.infoWindow.hide(); }); });
That just seems to hide the infoWindow as soon as it's shown - it's only up for a second.
function hideInfoWindow(){ map.infoWindow.hide(); }
Thanks Steven! That did it!
dojo.connect(map, "onClick", function(evt) { if(!evt.graphic) { console.log("map click"); } hideInfoWindow(); }); function hideInfoWindow(){ map.infoWindow.hide(); }
dojo.connect(map, "onClick", function(evt) { if(!evt.graphic) { map.infoWindow.hide(); } });
Is a polygon tiled layer used as a basemap considered a graphic? Or only the dynamic feature layer?
I'll also want to hide the infoWindow if scale changes beyond the visible scale range for the layer
Try moving that listener immediately underneath the map declaration
hard-code something in your code, then check the current scale range on each zoom change
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.