var layers = map.getLayersBy("visibility", true);
var activeLayer = null;
for (var i=0, len=layers.length; i<len;i++) {
if (layers[i].isBaseLayer === false) {
activeLayer = layers[i];
}
}
alert(activeLayer.name);
Best regards,
Bart
> But If I test the result:
>
> alert("activeLayer"+activeLayer.name);
>
> I get the name of the baseLayer, and active layer is another one... ¿?
>
> Toni.
>
> -----Missatge original-----
> De: Bart van den Eijnden (OSGIS) [mailto:[email protected]]
> Enviat: miércoles, 17 de noviembre de 2010 14:55
> Per a: [email protected]
> A/c: Vidal, Antoni; [email protected]
> Tema: Re: [OpenLayers-Users] How to get active layer
>
> Typo, I meant:
> var activeLayer = layers[0];
>
> Best regards,
> Bart
>
>> var layers = map.getLayersBy("visibility", true);
>> // assuming there is only 1
>> var activeLayer = layers[1];
>>
>> Best regards,
>> Bart
>>
>>> Hello,
>>>
>>>
>>>
>>> How can I get active layer. Understanding that "Active layer" is the
>>> visible layer in the moment?.
>>>
>>>
>>>
>>> Thanks in advance
>>>
>>>
>>>
>>> Antoni Vidal
>>>
>>> Unitat d'Aplicacions SIG-WEB
>>> Institut Cartogràfic de Catalunya
>>> <http://mercuri.icc.cat/website/mob_nf/mob1/mob2/inici2.htm?CONSULTA=Institut%20Cartogr%25E0fic%20de%20Catalunya&XYADDRESS=429486:4580392>
>>> Parc de Montjuïc, E-08038 Barcelona
>>> Tel. (+34) 93 567 15 00 (ext. 3228)
>>> www.icc.cat <http://www.icc.cat/>
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> [email protected]
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>
>>
>>
>
>
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users