Is there a way to use layer.hide(); for multiple layers in a single function?... if only atmLayer is on, it won't shut off, with the error that bikeLayer is not defined
Hi Ben,You could define an array of layers, and add each layer to the array when it is defined. Then iterate through the array and switch off each layer.Something like this:
//define the array of layers - add each layer as it's created
var mapLayers = [];
mapLayers.add(bikeLayer);
mapLayers.add(atmLayer); //etc
//To switch off the layers
for (var i = 0; i < mapLayers.length - 1; i++) {
mapLayers.hide()
}
Hope this helps,Steve