AnsweredAssumed Answered

listing of layers with indexof causes issues

Question asked by lkoumis on Jan 7, 2016
Latest reply on Jan 7, 2016 by rscheitlin

This is a rather bizarre behavior when I use the indexof to find layer names that contain "Buffer".

 

So by running this:

array.forEach(this.map.graphicsLayerIds, function(layerId) {  
          var layer = this.map.getLayer(layerId);  
          console.log(layer.name);
        }, this);  

 

I get this output:

I modified it to capture only the layer names containing "Buffer", so I run this:

 

array.forEach(this.map.graphicsLayerIds, function(layerId) {  
          var layer = this.map.getLayer(layerId);
  if((layer.name).indexOf("Buffer") > -1){
  console.log(layer.name);
  }
        }, this);

 

and I get this:

meaning that the layer is undefined!!!

Ideas?

 

Thank you.

Outcomes