[OpenLayers-Users] Switching to singleTile mode (and back) on
the fly
Jon Blower
jdb at mail.nerc-essc.ac.uk
Wed Dec 5 04:52:25 EST 2007
> You can force
> this by doing layerswitcher_control.layerStates = []; to clear out the
> layerStates, which will cause it to redraw.
Thanks Christopher, that worked a treat. To summarize, the code
sequence that works is:
myLayer.displayInLayerSwitcher = false;
layerSwitcher.layerStates = [];
layerSwitcher.redraw();
Jon
On Dec 4, 2007 9:42 PM, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Tue, Dec 04, 2007 at 09:33:41PM +0000, Jon Blower wrote:
> > 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.
>
> You need to change the state of the LayerSwitcher -- by turning a layer
> on or off using setVisibility -- before it will redraw. You can force
> this by doing layerswitcher_control.layerStates = []; to clear out the
> layerStates, which will cause it to redraw.
>
> 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
--------------------------------------------------------------
More information about the Users
mailing list