[OpenLayers-Users] Starting function if layerstatus is changed

Kai Behncke Kai-Behncke at gmx.de
Fri Aug 14 09:20:07 EDT 2009


Dear users,


problem solved.
In

.....openlayers/lib/OpenLayers/Layers.js

an

    setVisibility: function(visibility) {
 //alert (ows.visibility);  
        if (visibility != this.visibility) {
            this.visibility = visibility;
            this.display(visibility);
            this.redraw();
            if (this.map != null) {
                this.map.events.triggerEvent("changelayer", {
                    layer: this,
                    property: "visibility"
                });
            }
            this.events.triggerEvent("visibilitychanged");
            
  
          if (my_layer.visibility!=true){
          alert ("false");
          .....
          ..........
          }
      }

...does what I want.

Best regards and Thank you, Kai
-------- Original-Nachricht --------
> Datum: Fri, 14 Aug 2009 16:15:11 +0300
> Von: Adrian Popa <adrian_gh.popa at romtelecom.ro>
> An: Kai Behncke <Kai-Behncke at gmx.de>
> CC: users at openlayers.org
> Betreff: Re: [OpenLayers-Users] Starting function if layerstatus is changed

> 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.popa at romtelecom.ro>
> >> An: Kai Behncke <Kai-Behncke at gmx.de>
> >> CC: users at 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
> 

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01



More information about the Users mailing list