Layer List Widget nodes not synchronizing for dynamic layer

470
1
Jump to solution
11-30-2018 01:33 PM
arunepuri1
New Contributor III

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 

Water_Network (MapServer) 


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

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
arunepuri1
New Contributor III

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);
}

}

});

View solution in original post

0 Kudos
1 Reply
arunepuri1
New Contributor III

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);
}

}

});

0 Kudos