[OpenLayers-Users] Switching to singleTile mode (and back) on the fly

Jon Blower jdb at mail.nerc-essc.ac.uk
Tue Dec 4 16:33:41 EST 2007


OK, attached is an HTML file that shows the problem.  As you can see
from the code I'm doing the following:

1) Creating two overlay layers, only one of which is to be displayed
in the layer switcher
2) Adding both overlays to the map
3) Toggling the displayInLayerSwitcher property of each overlay layer
4) Redrawing the layer switcher control

Initially nothing changes as a result of (3) and (4), i.e. the layers
that are displayed in the switcher don't change.  However, if you
click the overlay's checkbox in the layer switcher it seems to sort
itself out and work correctly.

So, it seems that the layer switcher only redraws when it is clicked.

I hope this is enough to go on!

Regards, Jon

On Dec 4, 2007 7:00 PM, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Tue, Dec 04, 2007 at 06:17:08PM +0000, Jon Blower wrote:
> > Hi Christopher,
> >
> > > Have two layers, and switch between them? You don't have to display them
> > > both: when you switch, set the one you'r turning 'off' to
> > > displayInLayerSwitcher false, then call cahngebaseLayer (or
> > > setVisibility, if they are overlays) and change the layer.
> >
> > I've just tried this and don't quite get the result I expect.  If I
> > change the property displayInLayerSwitcher after a layer has been
> > added to the map, nothing happens, even if I call
> > layerSwitcher.redraw().
> >
> > Is there a way to add or remove a layer from the layer switcher after
> > the layer has been added to the map?
>
> I'm surprised this doesn't work. Can you craft a simple HTML example
> demonstrating it that you can share?
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
>



-- 
--------------------------------------------------------------
Dr Jon Blower              Tel: +44 118 378 5213 (direct line)
Technical Director         Tel: +44 118 378 8741 (ESSC)
Reading e-Science Centre   Fax: +44 118 378 6413
ESSC                       Email: jdb at mail.nerc-essc.ac.uk
University of Reading
3 Earley Gate
Reading RG6 6AL, UK
--------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20071204/e3af426a/possibleLayerSwitcherBug.html


More information about the Users mailing list