Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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;



share|improve this answer

Your Answer


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.