[OpenLayers-Dev] Layer Switcher Issue with Base Layers

Ganesh Jothikumar ganeshjothikumar at yahoo.com
Wed Nov 28 07:32:33 EST 2007


Hi All

         I have tried out the Layer SWitcher Event Listener as per ticet http://trac.openlayers.org/ticket/878

I have an issue with the Layer SWitcher event listener. I have two base layers and I have created listeners for both based on 'visibilitychanged' But the listener of the layer selected is not getting invoked rather teh listener of the later which was selected  last is getting invoked. Basically if by default base layer1 was selected ad now in layer swtcher we select base layer2 then  listener of baselayer 1 is getting invoked


For eg: 

          tiled1 = new OpenLayers.Layer.WMS(
            "Floor Plan", "http://localhost:8080/geoserver/wms",
            {
              srs: 'EPSG:4326',
              layers: 'topp:OfficeFloorPlan',
              format: 'image/png', tiled: 'true'
            }
          );
          map.addLayer(tiled1);

    tiled2 = new OpenLayers.Layer.WMS(
            "Floor Plan", "http://localhost:8080/geoserver/wms",
            {
              srs: 'EPSG:4326',
              layers: 'topp:OfficeFloorPlan',
              format: 'image/png', tiled: 'true'
            }
          );
          map.addLayer(tiled2);


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

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

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

In the above when I select tiled1 tiled2 event listener is getting invoked and vice versa. But the expectation is vice versa. When I select tiled1 base layer tiled1 listener should be invoked.  Is 'visibilitychanged' the only keyword. Is there any other listener whihc invokes the correct listener when that layer is selected. Or is this a bug.

Please help me out with this..

Thanks
ganesh


      Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20071128/2b4af0ae/attachment.html


More information about the Dev mailing list