[OpenLayers-Users] How to select WMS layers on one OpenLayer.Layer.WMS layer dynamically?

Diego Guidi diegoguidi at gmail.com
Mon Jan 2 02:23:12 EST 2012


> is there some kind of "layer switcher" which allows me to select the WMS
> layers for one WMS layer?
AFAIK there isn't any specific control, i.e. layer switcher, but it's
easy to do the task you need.
Create a graphic list of your layers, as example using checkboxes (or
a treeview using extjs, or...)
and anytime a checkbox is checked/unchecked, simply call
   wmsLayer.mergeNewParams(...);
passing it an object with only the selected layers { layers:
'myLayer1, mylayer2 '}.
http://dev.openlayers.org/docs/files/OpenLayers/Layer/WMS-js.html#OpenLayers.Layer.WMS.mergeNewParams
then call
   wmsLayer.redwaw(true);


More information about the Users mailing list