[OpenLayers-Users] Starting function if layerstatus is changed
Adrian Popa
adrian_gh.popa at romtelecom.ro
Fri Aug 14 08:37:30 EDT 2009
Hello Kai,
Not sure if this is what you're looking for, but I registered my
function to run when the layer changes visibility (is toggled on/off):
markers.events.on({ "featureselected": onMarkerSelect,
"featureunselected": onMarkerUnselect, *"visibilitychanged":
onMarkerToggle* });
markers is a Vector layer, but the event should be available for every
layer. You can check in your function to see if the layer has been
toggled off or on by looking at markers.visibility:
*function onMarkerToggle(event) {
//do something if visibility becomes true
if(markers.visibility == true){
alert("This layer just turned visible!");
}
}
*
Regards,
Adrian
Kai Behncke wrote:
> Dear users,
>
>
>
>
> I would like to start a function if the layer is on/off.
>
> I tried e.g.
>
>
> if (this.map.events.triggerEvent("changelayer")){
> alert ("here we go");
> }
>
>
> and
>
> if (my_layer.display()){
>
> alert ("here we go");
> }
>
>
> ...but so far without success.
> Can anybody help please?
>
> Thank you very much, Kai
>
--
---
Adrian Popa
NOC Division
Network Engineer
Divizia Centrul National de Operare Retea
Departament Transport IP & Metro
Compartiment IP Core & Backbone
Phone: +40 21 400 3099
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090814/25541e26/attachment.html
More information about the Users
mailing list