Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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 have an init-Function, there some layers are added with the option displayInLayerSwitcher = false; Thats ok, but in some situations i need to set this later in the application to true. So i want to reset the option. The ways i tried to figure out:


my_layer.displayInLayerSwitcher = true;
// Result is, that my_layer is resetted and in the LayerSwitcher nothing changed.


my_layer.displayInLayerSwitcher = true;
my_layers_switcher = new OpenLayers.Control.LayerSwitcher();
// Same Result as by way 1

Anyone, who have an idea for this?

share|improve this question
map.layers[i].displayInLayerSwitcher = false; //i is your layer number.

i hope it helps you...

share|improve this answer
Hello, thank you. I found out, why it doesn't worked. Sometimes, you can't see the forest through the trees. It's a little bit shameful, because i did not made the layer-variable global. So i could not access it in my function. only setting displayInLayerSwitcher = false; is working. – FreshAir Nov 6 '12 at 12:31

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.