Hello Kai,

Are you trying to turn the layer on/off from outside the Layer Switcher?

Regards,
Adrian

Kai Behncke wrote:
Hi Adrian, Hi Alexandre,


thank you for your hints, nevertheless I didn`t get it.


With "my_layer.visibility" I will get easily the status (true/false),
but the problem I have is that I don`t know how to get the function 
setVisibility() (that is called after activatin/deactivating a layer in 
Control.LayerSwitcher).

I mean:
I turn the layer on/off and the function obviously is called.

But how can I do a request on that?


Something like:

if (setVisibility()) {
alert ("change");
alert (my_layer.visibility);
}
of
If this.map.events.triggerEvent("visibilitychanged")) {
...
....
}

Well, I will try on.....


Best regards, Kai








-------- Original-Nachricht --------
Datum: Fri, 14 Aug 2009 15:37:30 +0300
Von: Adrian Popa <adrian_gh.p...@romtelecom.ro>
An: Kai Behncke <kai-behn...@gmx.de>
CC: users@openlayers.org
Betreff: Re: [OpenLayers-Users] Starting function if layerstatus is changed

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




--
--- 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

_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

Reply via email to