[OpenLayers-Dev] OL LayerSwitcher Listener

Ganesh Jothikumar ganeshjothikumar at yahoo.com
Tue Nov 27 10:27:27 EST 2007


Hi

    Thanks for the link. I read through the ticket and feel that this answers my question. But what I could not figure out is how to use teh event listener. I have a layer like the below

          var untiled_layer = new OpenLayers.Layer.WMS.Untiled(
            "Overlay Layer", "http://localhost:8080/geoserver/wms",
            {
             filter:'(<Filter><PropertyIsEqualTo><PropertyName>frequencyspec</PropertyName>
            <Literal>BG</Literal></PropertyIsEqualTo></Filter>)',
            srs: 'EPSG:4326',
            layers: 'topp:radio',
            transparent: 'true',
            format: 'image/png'
            },
            {isBaseLayer: false, maxExtent: bounds} 
          );
          untiled_bgCoverage.ratio=1;
          untiled_bgCoverage.setVisibility(true);
          map.addLayer(untiled_bgCoverage);

And I add the layer switcher as below

        map.addControl(new OpenLayers.Control.LayerSwitcher());

Now I tried adding the event listener in two ways . But doesn't work

1)
        map.events.register('layerswitched', map, function (e) {
       log(" ----------- Visibility Changed --------------- ");
          });

2)
      untiled_devices.events.register('visibilitychanged', untiled_devices, function (e) {
       log(" ----------- Visibility Changed --------------- ");
      });

But whenever I change the layers in the Layer Switcher teh log is not getting printed. Am I doing it the right way. If not please let me know the way with a few lines of code. Also I need to get the selected layers in the switcher from inside the listener.

                  Lastly how do I apply the patch. How do I merge it with the existing OpenLayers.js in my machine. Is it enough if I downlod the latest from openlayers.org. It will be very helpful if someone guides me with this issue

Thanks in advance
ganesh


----- Original Message ----
From: Christian López Espínola <penyaskito at gmail.com>
To: Ganesh Jothikumar <ganeshjothikumar at yahoo.com>
Cc: dev at openlayers.org
Sent: Monday, 26 November, 2007 7:36:15 PM
Subject: Re: [OpenLayers-Dev] OL LayerSwitcher Listener

Hi Ganesh,

I found this ticket with a patch attached, maybe it can help you.

http://trac.openlayers.org/ticket/878

Hope this helps.

On 11/26/07, Ganesh Jothikumar <ganeshjothikumar at yahoo.com> wrote:
>
> Hi All
>
>          I am using OpenLayers to display mutiple base layers and multiple
> overlays. Now I am using the Layer Switcher provided by OL API
> (map.addControl(new OpenLayers.Control.LayerSwitcher()))
> Now I have a requirement wherin depending on the layer selection in the
> Layer Switcher I have to filter the data. Is there a way wherin I can have a
> event listener for a Layer Switcher i.e. whenever someone changes the
> selection in the switcher a Java Script function needs to be called. And
> also I should be able to get teh list of selected layers in the switcher
> inside the function. Please let me know any way to do this. Any example
> would be vey helpful..
>
> Thanks in advance
> ganesh
>  ________________________________
>  Unlimited freedom, unlimited storage. Get it now
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
>


-- 
Regards,

Christian López Espínola


      Forgot the famous last words? Access your message archive online at http://in.messenger.yahoo.com/webmessengerpromo.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20071127/4bf3a4d5/attachment.html


More information about the Dev mailing list