[OpenLayers-Users] Switching to singleTile mode (and back) on
the fly
Erik Uzureau
erik.uzureau at metacarta.com
Thu Jan 3 15:18:14 EST 2008
seems like maybe it would be nice to have layer switcher's redraw()
re-init the layerStates array automatically? or if not automatically,
at least via a parameter to the function or something.... the
layerStates property to me should be a private of the layerswitcher,
that no user should need to know about and certainly not modify...
thoughts?
erik
On 12/5/07, Jon Blower <jdb at mail.nerc-essc.ac.uk> wrote:
> > 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
> --------------------------------------------------------------
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list