3

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:

1:

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

2:

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

Anyone, who have an idea for this?

3
map.layers[i].displayInLayerSwitcher = false; //i is your layer number.
map.layers[].setVisibility();

i hope it helps you...

|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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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