Read from config file

848
4
Jump to solution
02-15-2017 08:46 AM
LefterisKoumis
Occasional Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   What version of WAB LayerList widget are you working with? The LayerListView contructor does not have a layers property.

0 Kudos
LefterisKoumis
Occasional Contributor III

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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

LefterisKoumis
Occasional Contributor III

Got it. Thanks.

0 Kudos