[OpenLayers-Users] Using a select box for the layerswitcher

Jay Douillard jay.douillard at ubc.ca
Tue Jul 14 14:22:52 EDT 2009


Hello, I'm currently trying to modify a section of the layerswitcher( http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js ). 

I'm using a select box rather than radio buttons for the baselayers.   
Changed code here: http://dpaste.com/67067/ 
Example of usage:  http://map.earlylearning.ubc.ca/layer.html


The logic behind the layerswitcher is to attach an event to each radio button, or checkbox, with the correct context. This can't be done with  <select> as you can't attach events to <option> tags. So I've used the onchange on the select tag.

The event fires onchange, and gets the correctly selected value. The select box changes on a map.setBaseLayer(layer_name) to the correct option. But changing the select isn't changing the baselayer(see example)!!


Thanks!
 
----
Jay 



More information about the Users mailing list