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'm using OpenLayers with mapserver to display a lot of raster images and queryable wms layers. Everything works fine, the layers can be turned on/off in the OpenLayers layer switcher...But now I want to turn on/off the layers by external checkboxes and I don't know how to do this.

I'm little bit new to Javascript-the only thing I know is that I have to pass the checkbox layer value to an OpenLayers function. Till now I tried to call a function with an onClick event

<input type="checkbox" name="ckeckbox_layer1" onClick="layervisibility(this.checked);">

But I don't know how the function 'layervisibility' has to look like so that my layers that are actually placed in the openlayers init() function turn on/off correctly when I check/uncheck the checkboxes.

share|improve this question
1  
Thanks for your answer, I found an example on working exampleand it works perfect for me. –  user10545 Sep 27 '12 at 13:56
2  
Probably the OpenLayers Cookbook can help you (packtpub.com/openlayers-create-gis-web-applications-cookbook/…) –  EricSonaron Sep 28 '12 at 18:00
    
Your working example is very useful. Thanks for sharing it! –  Stefan Nov 29 '12 at 20:21

1 Answer 1

Try the following:

layer.setVisibility(true)

Lots of examples here: http://openlayers.org/dev/examples/

share|improve this answer

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.