[OpenLayers-Dev] Layer switched event
Bart van den Eijnden
bartvde at osgis.nl
Wed Mar 16 07:45:16 EDT 2011
Hi,
just listen for the changelayer event on the Map, and check for evt.property == "visibility".
Best regards,
Bart
--
Looking for flexible support on OpenLayers or GeoExt? Please check out http://www.osgis.nl/support.html
Bart van den Eijnden
OSGIS
bartvde at osgis.nl
On Mar 16, 2011, at 12:42 PM, Martin Saturka wrote:
> 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
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>
More information about the Dev
mailing list