Is it possible to enable popup by default for each map service / feature service loaded in the layer list by Geoportal Search widget ad Add Data Widget?
We are using WAB 2.1 developer ed.
Thank you very much in advance!
Enrico
Solved! Go to Solution.
Enrico,
I did not test that. Here are the tested changes:
[install dir]\server\apps\[app#]\jimu.js\LayerInfos\LayerInfoForDefaultService.js:
_initControlPopup: function() {
var mapServiceLayer = this.originOperLayer.mapService.layerInfo.layerObject;
var subId = this.originOperLayer.mapService.subId;
setTimeout(lang.hitch(this,function(){
this.loadInfoTemplate().then(lang.hitch(this, function(){
this.enablePopup();
}));
}), 500);
this.controlPopupInfo = {
enablePopup: (mapServiceLayer.infoTemplates && mapServiceLayer.infoTemplates[subId]) ?
true:
false,
infoTemplates: undefined
};
},
[install dir]\server\apps\[app#]\jimu.js\LayerInfos\LayerInfoForDefault.js:
_initControlPopup: function() {
this.controlPopupInfo = {
//enablePopup: this.originOperLayer.disablePopup ? false : true,
enablePopup: this.layerObject.infoTemplate ? true: false,
infoTemplate: this.layerObject.infoTemplate
};
// backup infoTemplate to layer.
this.layerObject._infoTemplate = this.layerObject.infoTemplate;
aspect.after(this.layerObject, "setInfoTemplate", lang.hitch(this, function(){
this.layerObject._infoTemplate = this.layerObject.infoTemplate;
this.controlPopupInfo.infoTemplate = this.layerObject.infoTemplate;
if(!this.controlPopupInfo.enablePopup) {
this.layerObject.infoTemplate = null;
}
}));
setTimeout(lang.hitch(this,function(){
this.loadInfoTemplate().then(lang.hitch(this, function(){
this.enablePopup();
}));
}), 500);
},
Enrico,
This would involve modifying a couple of the core jimu files:
[install dir]\server\apps\[app#]\jimu.js\LayerInfos\LayerInfoForDefaultService.js (lines 5 - 😎
_initControlPopup: function() {
var mapServiceLayer = this.originOperLayer.mapService.layerInfo.layerObject;
var subId = this.originOperLayer.mapService.subId;
this.controlPopupInfo = {
// enablePopup: (mapServiceLayer.infoTemplates && mapServiceLayer.infoTemplates[subId]) ?
// true:
// false,
enablePopup: true,
infoTemplates: undefined
};
},
[install dir]\server\apps\[app#]\jimu.js\LayerInfos\LayerInfoForDefault.js (lines 4 & 5):
_initControlPopup: function() {
this.controlPopupInfo = {
//enablePopup: this.originOperLayer.disablePopup ? false : true,
//enablePopup: this.layerObject.infoTemplate ? true: false,
enablePopup: true,
infoTemplate: this.layerObject.infoTemplate
};
// backup infoTemplate to layer.
this.layerObject._infoTemplate = this.layerObject.infoTemplate;
aspect.after(this.layerObject, "setInfoTemplate", lang.hitch(this, function(){
this.layerObject._infoTemplate = this.layerObject.infoTemplate;
this.controlPopupInfo.infoTemplate = this.layerObject.infoTemplate;
if(!this.controlPopupInfo.enablePopup) {
this.layerObject.infoTemplate = null;
}
}));
},
Thank you Robert !
We modified the two files as you suggested: now the layer list widget opens with the "anable popup" activated but if you click on the map feature the popup doesn't appear.
Then if you manually disabe and re-anable the option, the popup appears.
Best
Enrico
Enrico,
I did not test that. Here are the tested changes:
[install dir]\server\apps\[app#]\jimu.js\LayerInfos\LayerInfoForDefaultService.js:
_initControlPopup: function() {
var mapServiceLayer = this.originOperLayer.mapService.layerInfo.layerObject;
var subId = this.originOperLayer.mapService.subId;
setTimeout(lang.hitch(this,function(){
this.loadInfoTemplate().then(lang.hitch(this, function(){
this.enablePopup();
}));
}), 500);
this.controlPopupInfo = {
enablePopup: (mapServiceLayer.infoTemplates && mapServiceLayer.infoTemplates[subId]) ?
true:
false,
infoTemplates: undefined
};
},
[install dir]\server\apps\[app#]\jimu.js\LayerInfos\LayerInfoForDefault.js:
_initControlPopup: function() {
this.controlPopupInfo = {
//enablePopup: this.originOperLayer.disablePopup ? false : true,
enablePopup: this.layerObject.infoTemplate ? true: false,
infoTemplate: this.layerObject.infoTemplate
};
// backup infoTemplate to layer.
this.layerObject._infoTemplate = this.layerObject.infoTemplate;
aspect.after(this.layerObject, "setInfoTemplate", lang.hitch(this, function(){
this.layerObject._infoTemplate = this.layerObject.infoTemplate;
this.controlPopupInfo.infoTemplate = this.layerObject.infoTemplate;
if(!this.controlPopupInfo.enablePopup) {
this.layerObject.infoTemplate = null;
}
}));
setTimeout(lang.hitch(this,function(){
this.loadInfoTemplate().then(lang.hitch(this, function(){
this.enablePopup();
}));
}), 500);
},
Thank you Robert!
now it works perfectly!
I am using WAB that is in Portal. Any way to do the same with that?
Brain,
Portal is a different animal I personally do not use or have experience with. If the code is not minified/uglified then it would be possible.
Hi Robert.
This has worked pretty well for me but I am wondering if it is possible to make this not set pop ups on basemaps. As it stands, the minute I change the basemap to something like imagery, it turns popups on for that. Depending on my zoom level, that could mean sifting through over 100 items in the popup to get what I need.
Brain,
In the LayerInfoForDefault.js make this change:
_initControlPopup: function() {
var mapServiceLayer = this.originOperLayer.mapService.layerInfo.layerObject;
var subId = this.originOperLayer.mapService.subId;
setTimeout(lang.hitch(this,function(){
this.loadInfoTemplate().then(lang.hitch(this, function(){
var bmFound = false;
this._layerInfos._finalBasemapLayerInfos.some(lang.hitch(this, function(bm){
if(this.id.indexOf(bm.id)>-1){
bmFound = true;
return true
}
}));
if(!bmFound){
this.enablePopup();
}
}));
}), 500);
this.controlPopupInfo = {
enablePopup: (mapServiceLayer.infoTemplates && mapServiceLayer.infoTemplates[subId]) ?
true:
false,
infoTemplates: undefined
};
},
Before I make that change I want to verify you meant to change the LayerInfoForDefault.js and not LayerInfoForDefaultService.js. The only reason I ask is that the code you changed looks more like the latter file LayerInfoForDefaultService.js