[OpenLayers-Users] How to select a particular layer

Arnd Wippermann arnd.wippermann at web.de
Mon Aug 18 12:50:03 EDT 2008


A simple way is to build a dropdown list with the layer names to set the
active layer. 

http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/labels.html 

function populateLayer(aktLyr)
{
    //populate select for layers
    var theHTML = '<select id="selAktLyr" onchange="setAktLyr();">';
    for(var i=4;i<map.layers.length;i++) //exclude Google layers 0-3
    {
        theHTML += '<option value=' + i + '>' + map.layers[i].name;
    }
    document.getElementById("spanselAktLyr").innerHTML = theHTML +
'</select>';
    if(!aktLyr)
        map.aktLayer = 4;
    else
    {
        map.aktLayer = aktLyr;
    }
    document.getElementById("selAktLyr").value=map.aktLayer;
}

function setAktLyr()
{
    map.aktLayer = document.getElementById("selAktLyr").value;
}

Arnd Wippermann


-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von fredth
Gesendet: Montag, 18. August 2008 17:27
An: users at openlayers.org
Betreff: [OpenLayers-Users] How to select a particular layer


Hey, I want to do a getInfo on a layer, but when the user has 2 or more
layers displayed, we can't find which layer he wants to query. Do you know
any way to let the user specify an "active" layer ? I've tried to modify the
legend, adding a radio-button, but I have a problem with it. When the user
select a layer, he can't change after. Also, if he decide to display a new
layer, the selected value disappear.

Also, if you have a better way that to use an "active" layer to do that, you
are welcome.

Thx
--
View this message in context:
http://www.nabble.com/How-to-select-a-particular-layer-tp19034039p19034039.h
tml
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list