[OpenLayers-Users] Inducing LayerSwitcher to Update Through
Programming
Christopher Schmidt
crschmidt at metacarta.com
Tue Feb 24 12:37:06 EST 2009
On Tue, Feb 24, 2009 at 09:51:03AM -0700, Bill Thoen wrote:
> Christopher Schmidt wrote:
> >map.setBaseLayer(map.layers[1])
> >on http://openlayers.org/dev/examples/controls.html cause the
> >ayerSwitcher to redraw for me. Does it not do that for you? It should;
> >if it doesn't, that's a bug.
> >
> Here's an example where a layer is switched under the LayerSwitcher's
> nose, and it doesn't react to it even if you call setBaseLayer() after
> the change: http://206.168.217.244/gallery/ToggleBaseLayer.html
setBaseLayer after the layer is *already* visible won't do anything,
that is correct. That's not how setBaseLayer is designed to be used.
Though this exposes a behavior in the LayerSwitcher, I don't think it's
a bug, because this demonstration seems a bit like an anti-use of the
library.
> I realize that if I had called setBaseLayer() first I wouldn't have to
> go through all that bit to change layer visibilities, but this "bug"
> appeared as a result of originally wanting to change overlay layers.
Overlay layers should react to setVisibility -- something that base
layers do differently. Can you find an overlay layer whiwch doesn't do
the right thing if you setVisiblity on it (via the method, rather than
via layer.visibility and layer.redraw() or somethign like that)?
> So is this a bug or not? I don't know. It looks like setBaseLayer() is
> designed to sense the environment and match the current state of
> affairs, but in this case it doesn't, so it's a bug. On the other hand,
> it's a "set" function which implies that it should be called to SET the
> environment and not doing this first is a programmer error, so it's not
> a bug. Perhaps someone who knows more about OpenLayers than I do could
> make the call.
>
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list