1

I'm trying to load a layer as an overlay and make it initially not visible

 airBoss = new OpenLayers.Layer.Text( "AirBoss Locations", { location:"./airboss.txt"} , {
 visibility: false, isBaseLayer: false, displayInLayerSwitcher: true});
 map.addLayer(airBoss);
 airBoss.setZIndex(210);
 airBoss.setVisibility = false;

Using this code with or without the additional "setVisibility" line the layer always is visible. Is this a bug in the JavaScript of OpenLayers or am I doing something wrong?

nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
asked Aug 11, 2012 at 22:17

1 Answer 1

2

setVisibility() is a function not an attribute. You just need to change the last line of your sample code to airBoss.setVisibility(false)

ref: http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.setVisibility

answered Aug 12, 2012 at 5:28
4
  • 1
    Duh !! Thanks of course. Thanks for the answer I'll try it today. Commented Aug 12, 2012 at 18:20
  • Works perfeectly now, however even though I have displayInLayerSwitcher: false (changed the code) it still shows it in the layer switcher Commented Aug 13, 2012 at 16:17
  • @MB - same question was just asked today. check it out. gis.stackexchange.com/questions/31370/… Commented Aug 13, 2012 at 17:34
  • Yeah this is exactly what I have in my script tried with and without the single quote marks. I think it works for WMS layers not text layers though Commented Aug 13, 2012 at 20:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.