AnsweredAssumed Answered

Hiding multiple feature layers

Question asked by bundarrabandito on Dec 21, 2011
Latest reply on Dec 21, 2011 by bundarrabandito
Hi all,

I've add some feature layers and pushed them into an array like below:

var dwf = "http://<server>/ArcGIS/rest/services/SLR/Water/MapServer/1";
dwfLayer = new esri.layers.FeatureLayer(dwf, {
id : "dwf",
title : "Drinking water facilities",
infoTemplate : infoTemplate
});
legendLayers.push({
layer : dwfLayer,
title : 'Drinking water facilities'
},

Then, in another function, I'd like to switch off all the feature layers so I've tried using:

var len = legendLayers.length;
for (var i = 0; i < len; i++) {
legendLayers[i].hide();
}

I've also tried:

dojo.forEach(legendLayers.layer, function(layer) {
layer.hide();
});

But neither of the above functions work to hide all the layers in the legendLayers array.  I'm obviously missing something. Can anyone help?

Thanks heaps,
Ed

Outcomes