I am trying to modify the script below to capture only a specific layer from the config file, let's the first one (index:0).
So instead of:
this.layerListView = new LayerListView({
layers: this.config.layers
}).placeAt(this.layerListBody);
I use
this.layerListView = new LayerListView({
layers: this.config.layers[0]
}).placeAt(this.layerListBody);
But the "layers" does not store anything.
The first one will store all layers.
Suggestions?
Thank you.
Solved! Go to Solution.
Ah. The AddLayer Widget that is helpful information. The LayerListView in that widget is expecting an array for the layers property, not just a single layer. you you need to create a new array with just the layer you want inside it then.
Lefteris,
What version of WAB LayerList widget are you working with? The LayerListView contructor does not have a layers property.
I am using v. 2.3.
I am trying to modify the AddLayer Widget widget so it includes only layers that meet certain criteria.
like below. If you use layers: this.config.layer it works but it captures all layers.
array.forEach(this.config.layers, function (layer) {
layer.isSelected = false;
if (layer.name === "climate"){
this.layerListView = new LayerListView({
layers: this.config.layer[0]
}).placeAt(this.layerListBody);
}
}, this);
Thanks.
Ah. The AddLayer Widget that is helpful information. The LayerListView in that widget is expecting an array for the layers property, not just a single layer. you you need to create a new array with just the layer you want inside it then.
Got it. Thanks.