If anyone cares, I have opened a ticket for this: http://trac.openlayers.org/ticket/1684
I probably won't look at it for a long while, but at least it is recorded somewhere. Erik On Thu, Jan 3, 2008 at 3:18 PM, Erik Uzureau <[EMAIL PROTECTED]> wrote: > 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] >> University of Reading >> 3 Earley Gate >> Reading RG6 6AL, UK >> -------------------------------------------------------------- >> _______________________________________________ >> Users mailing list >> [email protected] >> http://openlayers.org/mailman/listinfo/users >> > _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
