[OpenLayers-Dev] Layer switched event
Martin Saturka
martin.saturka at sourcefabric.org
Wed Mar 16 07:42:46 EDT 2011
Hi,
I could not find an event for situations when a layer is switched (by
the LayerSwitcher control). I did put a hook there for checking, but
may be that there is a better way for that. Could we have mentioned
that another better way somewhere, or to have a hook at the switcher,
like below, please?
OpenLayers.Control.LayerSwitcherMod =
OpenLayers.Class(OpenLayers.Control.LayerSwitcher, {
checkRedraw: function() {
var redraw = false;
if ( !this.layerStates.length ||
(this.map.layers.length != this.layerStates.length) ) {
redraw = true;
} else {
for (var i=0, len=this.layerStates.length; i<len; i++) {
var layerState = this.layerStates[i];
var layer = this.map.layers[i];
if ( (layerState.name != layer.name) ||
(layerState.inRange != layer.inRange) ||
(layerState.id != layer.id) ||
(layerState.visibility != layer.visibility) ) {
redraw = true;
break;
}
}
}
if (redraw)
{
OpenLayers.Hooks.LayerSwitcher.layerSwitched(this);
}
return redraw;
},
CLASS_NAME: "OpenLayers.Control.LayerSwitcher"
});
M.
--
Martin Saturka
Software Engineer, Sourcefabric
www.sourcefabric.org
More information about the Dev
mailing list