[OpenLayers-Users] Inducing LayerSwitcher to Update Through Programming

Christopher Schmidt crschmidt at metacarta.com
Mon Feb 23 11:36:40 EST 2009


On Mon, Feb 23, 2009 at 09:28:53AM -0700, Bill Thoen wrote:
> I've got a javascript application that changes the base layer of a map 
> as one of its operations and I was wondering what the most correct way 
> to update the LayerSwitcher control to reflect the changed base layer 
> would be. In LayerSwitcher.js I didn't see an obvious function like 
> setBaseLayer() or similar, and redraw() alone doesn't react to a changed 
> base layer. So what I did was set layerStates.length = 0 and called 
> redraw(). This works, but I was wondering if this is the best way to 
> handle it?

map.setBaseLayer(map.layers[1])
on http://openlayers.org/dev/examples/controls.html  cause the
LayerSwitcher to redraw for me. Does it not do that for you? It should;
if it doesn't, that's a bug.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list