[OpenLayers-Users] layerswitched event

Christopher Schmidt crschmidt at metacarta.com
Sun Mar 30 20:47:21 EDT 2008


On Mon, Mar 31, 2008 at 11:45:09AM +1100, bradleyspencer wrote:
> List,
> 
> Has anyone got an example of how to setup and use the ‘layerswitched’ event
> listener?
> 
> I want to do something when a particular layer is turned on.

You probably want the layer's 'visibilitychanged' event, then.

layer.events.register("visibilitychanged", layer, function() {
  if (this.getVisibility()) {
    alert("layer is on!");
  }
});

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list