In the draw widget's configuration, the user can choose to add the markup/drawing as an operational layer. I am wondering how I could enable a pop-up to the newly add layer by default? If the application has the OTB layer list widget, you can enable the popup there (as the new operational layer automatically gets added to the layer list), but I would like to skip that step and have the popup automatically enabled. Any help would be appreciated.
Solved! Go to Solution.
Matt,
In the Widget.js make this change to the _addLayerFromLayerInfos function (lines 11-16):
_addLayerFromLayerInfos: function(layer){
var loading = new LoadingIndicator();
loading.placeAt(this.domNode);
LayerInfos.getInstance(this.map, this.map.itemInfo)
.then(lang.hitch(this, function(layerInfos){
if(!this.domNode){
return;
}
loading.destroy();
layerInfos.addFeatureCollection([layer], this.label + "_" + layer.name);
setTimeout(() => {
var layerInfo = layerInfos.getLayerInfoById(this.label + "_" + layer.name + "_0");
if(layerInfo){
layerInfo.enablePopup();
}
}, 1000);
}), lang.hitch(this, function(err){
loading.destroy();
console.error("Can not get LayerInfos instance", err);
}));
},
Matt,
In the Widget.js make this change to the _addLayerFromLayerInfos function (lines 11-16):
_addLayerFromLayerInfos: function(layer){
var loading = new LoadingIndicator();
loading.placeAt(this.domNode);
LayerInfos.getInstance(this.map, this.map.itemInfo)
.then(lang.hitch(this, function(layerInfos){
if(!this.domNode){
return;
}
loading.destroy();
layerInfos.addFeatureCollection([layer], this.label + "_" + layer.name);
setTimeout(() => {
var layerInfo = layerInfos.getLayerInfoById(this.label + "_" + layer.name + "_0");
if(layerInfo){
layerInfo.enablePopup();
}
}, 1000);
}), lang.hitch(this, function(err){
loading.destroy();
console.error("Can not get LayerInfos instance", err);
}));
},
Works perfect. Thank you, Robert.