On Thu, Jun 10, 2010 at 11:59 AM, Rahn Hanno (rahn) <r...@zhaw.ch> wrote: > > Hello, > > Today I try to realise a "trigger" for my LayerSwitcher. Something like > "onLayerClick" or so. > > I want to start a function if I select/unselect a layer in the > Layerswitcher. In my Layerswitcher I have a Layer. If I select this Layer, > then I want to set the opacity from all other layers to 50%. If I unselect > the Layer the opacity should change again to not transparent. > > I think I need a trigger function for that layer. If I select some Layer I > would fire a function. I think it would be possible, but I don't know how to > realise. > > Perhaps somebody can help me. Or is there something like this already in > OpenLayers what I have not found?
Two options: - register a "changelayer" listener on the map map.on({ "changelayer": function(e) { if(e.property === "visibility") { alert("visibility changed (" + e.layer.name + ")"); } } }); - register a "visibilitychanged" listener on a specific layer layer.on({ "visibilitychanged": function() { alert"visibility changed (" + layer.name + ")"); } }); Hope it helps, -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : eric.lemo...@camptocamp.com http://www.camptocamp.com _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users