Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to have a checkbox in my layer switcher "turn all layers on/off". how can I do that ?

I thought about adding an empty layer with that name and somehow bind her an event "On Show" and "On Hide" to toggle the rest of the layers.

Any better solution ?

share|improve this question
add comment

1 Answer 1

I did this in code using check boxes in a that called a function. All the function did was to iterate through all the Layers and just make the visible or invisible.

For Example:

function layersOnOff(toggle){
    var LayerList = map.layers;
    for(var a = 0; a < LayerList.length; a++ ){
        LayerList[a].visibility = toggle;
    };
}

Cheers

Mark

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.