[OpenLayers-Users] set layer state
Christopher Schmidt
crschmidt at metacarta.com
Mon Dec 3 01:44:06 EST 2007
On Sun, Dec 02, 2007 at 08:36:38PM -0700, Richard Greenwood wrote:
> This probably isn't the best example, but in notile.html, old_ol_wms
> is the default selected base layer. So if I put the following two
> lines in, I expect to see the new_ol_wms radio button selected.
>
> old_ol_wms.setVisibility(false);
> new_ol_wms.setVisibility(true);
>
> I tried the above lines as the last two lines in init(), and also
> tried them in a script tag in the <body>
The canonical way to change base layers is the Map.setBaseLayer
function. setVisibility isn't enough -- not just for the layerswitcher,
but for other things as well. So, instead, you should do:
map.setBaseLayer(new_ol_wms);
setVisibility will turn on and off overlays well.
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list