Has anyone else experienced that identify still brings up a pop up for layers that aren't even turned on in the map? I am using a map published with Server and placed on ArcGIS Online.
I've noticed that. Perhaps more troubling, I've also noticed that popups don't work for layers that are off initially.
I have a web app that has multiple services from our ArcGIS Server. Most of the layers in each service are "off" (not visible) by default. They are also off in the web map. Popups for all layers are enabled. When I publish as a Web AppBuilder application, the popups for layers that are "off" do not show up, even after the end user turns the layer on in the Table of Contents widget.
My first work around is to turn all layers on in the web map. Now popups work, but as you've found, all layers in each service popup on every identify, even if some of the layers are off in the Table of Contents.
It is almost as if WebApp Builder does not correctly recognize when layers are on or off. Simply shows popups for anything you enabled in the web map. I had not noticed your further issue, but it would make sense if it can't correctly recognize settings from the actual map.
Hope Esri is looking into this. Kind of a deal breaker especially considering there isn't an actual identify tool you can control.
I'm experiencing the same problem. Any luck?
I'm using WAB on ArcGIS Online, not the Dev version.
The solution posted by Stan McShinsky seems to work (at least the first half - I haven't tested the second half) but it isn't available for the AGOL version. As Julia Guard noted, ESRI is aware of the issue, but hasn't committed to fixing it within any specific timeframe.
I have found that in the developer version you can go into the \jimu.js\MapManager.js file and make this change:
var webMapOptions = {
mapOptions: mapOptions,
bingMapsKey: appConfig.bingMapsKey,
usePopupManager: true
};
By adding the usePopupManager option it fixes the issue with identifying layers, but I find that it semi breaks other widgets like measure and draw because now when you click on the map to measure you get the measure tool and the identify popup comes up.
Stan,
I'm not familiar with the WAB code but you should be able to disable the popups when the measurement widget is active by setting map.showInfoWindowOnClick(false). Then when you deactivate the measure tool you can turn popups back on using map.showInfoWindowOnClick(true).
You may see that they already have code in the WAB that does this by enabling/disabling the clickEventHandler and clickEvent Listener. Once you set usePopupManager to true those no longer work and you have to switch to the showInfoWindowOnClick approach.
Hope this helps.
Kelly,
Thanks for the help. After you mentioned using map.showInfoWindowOnClick I tried to look it up but there was not much out there for that. All I found was this link esri/arcgis/utils | API Reference | ArcGIS API for JavaScript that has this When using usePopupManager: true
in the options
parameter in the createMap
method, the clickEventHandle
and clickEventListener
will be undefined. Instead use the Map.setInfoWindowOnClick
to control visibility of the popup. It did not give any examples on how to do that. I tried a few things and I think I found one that works. From what I can tell it looks good to me.
For the measurement widget I opened \widgets\Measurement\Widget.js and commented out two lines and added two new ones right around line 69.
aspect.after(this.measurement, 'setTool', lang.hitch(this, function() { if (this.measurement.activeTool) { //this.disableWebMapPopup(); this.map.setInfoWindowOnClick(false); //added this } else { //this.enableWebMapPopup(); this.map.setInfoWindowOnClick(true); //added this } }));
It looks like you need to add these lines of code to other widgets that need map clicks like draw.
OK I did some more digging and found the place to fix the draw widget.
\jimu.js\dijit\DrawBox.js
around line 165
Comment out this.enableWebMapPopup(); and add in this.map.setInfoWindowOnClick(true);
deactivate:function(){ //this.enableWebMapPopup(); this.map.setInfoWindowOnClick(true); //Added this if(this.drawToolBar){ this.drawToolBar.deactivate(); } query('.draw-item',this.domNode).removeClass('selected'); },
around line 245
Comment out this.disableWebMapPopup(); and add in this.map.setInfoWindowOnClick(false);
_onItemClick:function(event){ var target = event.target||event.srcElement; var items = query('.draw-item',this.domNode); items.removeClass('selected'); html.addClass(target,'selected'); var geotype = target.getAttribute('data-geotype'); var commontype = target.getAttribute('data-commontype'); var tool = Draw[geotype]; //this.disableWebMapPopup(); this.map.setInfoWindowOnClick(false); // added this this.drawToolBar.activate(tool); this.onIconSelected(target,geotype,commontype); },
Thanks Stan,
This worked for the measure tool. I didn't have quite as much luck with the draw widget. I tried switching setInfoWindowOnClick in the startup and destroy functions of the draw widget. startup seemed to work, but destroy did not give the popup back to Identify. Here's my code starting on line 371 of the Widget.js of the Draw Widget. (I don't seem to have access to the syntax highlighter in my forum window here.)
destroy: function() {
if(this.drawBox){
this.drawBox.destroy();
this.drawBox = null;
}
if(this.pointSymChooser){
this.pointSymChooser.destroy();
this.pointSymChooser = null;
}
if(this.lineSymChooser){
this.lineSymChooser.destroy();
this.lineSymChooser = null;
}
if(this.fillSymChooser){
this.fillSymChooser.destroy();
this.fillSymChooser = null;
}
if(this.textSymChooser){
this.textSymChooser.destroy();
this.textSymChooser = null;
}
this.inherited(arguments);
this.map.setInfoWindowOnClick(true); //<<ADDED THIS LINE
},
startup: function() {
this.map.setInfoWindowOnClick(false); //<<ADDED THIS LINE //<<ADDED THIS LINE
this.inherited(arguments);
this.viewStack.startup();
this.viewStack.switchView(null);
}