[OpenLayers-Users] OPENLAYERS LayerChange

Rahn Hanno (rahn) rahn at zhaw.ch
Thu Jun 10 08:32:07 EDT 2010


That's it.

Thank you very much for your help.

Greetings
Hanno


------------------------------------------
Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik
ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen 
Fachstelle Geoinformatik 
Grüental, Postfach CH-8820 Wädenswil 
Tel +41 (0)58 934 5592
Fax +41 (0)58 934 5580 
hanno.rahn at zhaw.ch
www.iunr.zhaw.ch/geoinformatik

 
 

-----Ursprüngliche Nachricht-----
Von: Eric Lemoine [mailto:eric.lemoine at camptocamp.com] 
Gesendet: Donnerstag, 10. Juni 2010 14:12
An: Rahn Hanno (rahn)
Cc: users at openlayers.org
Betreff: Re: [OpenLayers-Users] OPENLAYERS LayerChange

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.150
> 000),
>                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