Hi All,
I am using WAB 2.8 default Layer List widget.
When I add any dynamic layer to the map through another custom widget as per below code.
the map is showing properly with the visible layers which are provided with a SetVisibleLayers option. But the same is not reflecting in LayerList widget and default it is considering map service Default Visibility property and showing all nodes as checked even though on the map that layers are not visible.
Code:
I added a sample water network map service
var dynamicLayer = new ArcGISDynamicMapServiceLayer(url, {
'visible': dynamicData[key].visible,
'opacity': dynamicData[key].opacity
});
dynamicLayer.setVisibleLayers([-1,-1,20,21,23]);
map.addLayer(dynamicLayer);
Please suggest, if I am missing any code/ property which needs to set.
Thanks,
Arun E
Solved! Go to Solution.
The issue is resolved by using below code
// To get the layerInfosObj from
LayerInfos.getInstance(this.map, this.map.itemInfo).then(function (layerInfosObj) {
layerInfosObj.traversal(lang.hitch(this, function (layerInfo) {
if (arrayUtils.indexOf(dynamicLayer .visibleLayers, layerInfo.id) > -1) {
layerInfo._setTopLayerVisible(true);
} else {
layerInfo._setTopLayerVisible(false);
}
}
});
The issue is resolved by using below code
// To get the layerInfosObj from
LayerInfos.getInstance(this.map, this.map.itemInfo).then(function (layerInfosObj) {
layerInfosObj.traversal(lang.hitch(this, function (layerInfo) {
if (arrayUtils.indexOf(dynamicLayer .visibleLayers, layerInfo.id) > -1) {
layerInfo._setTopLayerVisible(true);
} else {
layerInfo._setTopLayerVisible(false);
}
}
});