[OpenLayers-Users] OPENLAYERS LayerChange

Eric Lemoine eric.lemoine at camptocamp.com
Thu Jun 10 08:12:25 EDT 2010


On Thu, Jun 10, 2010 at 2:04 PM, Rahn Hanno (rahn) <rahn at zhaw.ch> wrote:
>
> Super,
>
> That works. And how can I register a changelayer listener on the map? I try this:
>
> var options1 = {
>                maxExtent: new OpenLayers.Bounds(662642.346412,152155.850000,726497.716088,206636.150000),
>                maxResolution:'auto',
>                numZoomLevels: '9',
>                fractionalZoom: true,
>                scales: [500000, 250000, 200000, 125000, 100000, 75000, 50000, 25000, 10000],
>                units: 'm',
>                projection: "EPSG:21781",
>                controls: []
> };
>
> var map = new OpenLayers.Map('map',options1,
>        eventListeners: {
>                "changelayer": function(e) {
>                        if(e.property === "visibility") {
>                        alert("visibility changed (" + e.layer.name + ")");
>                        }
>                }
>        }
> );
>
> It doesn't work.

eventListeners must be set in the map options

new OpenLayers.Map('map', {
    eventListeners: {
               "changelayer": function(e) {
                       if(e.property === "visibility") {
                            alert("visibility changed (" + e.layer.name + ")");
                       }
               }
       }
});


-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list