openlayers / ol2

OpenLayers v2 - deprecated!
Other
1.47k stars 770 forks source link

LayerSwitcher displayed in a div redraws to default on layer change. #1137

Open kngai opened 11 years ago

kngai commented 11 years ago

I am using jQuery (2.0.x) and OL ver 2.12. I have my LayerSwitcher displayed outside my map in a div.

map.addControl(new OpenLayers.Control.LayerSwitcher({'div': $('#my_layerswitcher')[0]}));
prettifyMyLayerSwitcher();

But I noticed that as soon as I click to change layers, the LayerSwitcher div resets everything back to default, removing all my dynamic changes that I've applied to the div (ie. my CSS changes, adding custom JS functionality and jQuery UI elements).

I can't seem to find a solution or a similar problem reported by someone else. Is this a bug? How do I stop it from redrawing on layer change?

In the meantime, I have a workaround by reapplying my changes on changelayer event but that doesn't solve the problem and limits my customization:

map.events.register('changelayer', map, function(evt) {
    prettifyMyLayerSwitcher();
});
frankydp commented 11 years ago

Will try to get this fixed and submitted this weekend.