<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello Kai,<br>
<br>
Are you trying to turn the layer on/off from outside the Layer Switcher?<br>
<br>
Regards,<br>
Adrian<br>
<br>
Kai Behncke wrote:
<blockquote cite="mid:20090814130214.24140@gmx.net" type="cite">
  <pre wrap="">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 --------
  </pre>
  <blockquote type="cite">
    <pre wrap="">Datum: Fri, 14 Aug 2009 15:37:30 +0300
Von: Adrian Popa <a class="moz-txt-link-rfc2396E" href="mailto:adrian_gh.popa@romtelecom.ro">&lt;adrian_gh.popa@romtelecom.ro&gt;</a>
An: Kai Behncke <a class="moz-txt-link-rfc2396E" href="mailto:Kai-Behncke@gmx.de">&lt;Kai-Behncke@gmx.de&gt;</a>
CC: <a class="moz-txt-link-abbreviated" href="mailto:users@openlayers.org">users@openlayers.org</a>
Betreff: Re: [OpenLayers-Users] Starting function if layerstatus is changed
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">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:
    </pre>
    <blockquote type="cite">
      <pre wrap="">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
  
      </pre>
    </blockquote>
    <pre wrap="">
-- 
--- 
Adrian Popa
NOC Division
Network Engineer
Divizia Centrul National de Operare Retea
Departament Transport IP &amp; Metro
Compartiment IP Core &amp; Backbone
Phone: +40 21 400 3099

    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
--- 
Adrian Popa
NOC Division
Network Engineer
Divizia Centrul National de Operare Retea
Departament Transport IP &amp; Metro
Compartiment IP Core &amp; Backbone
Phone: +40 21 400 3099
</pre>
</body>
</html>