[OpenLayers-Users] Layers in drop down

Adam Eskreis aeskreis at gmail.com
Mon Nov 28 13:45:17 EST 2011


You don't HAVE to use the OpenLayers  layer switcher control.  You can make
your own from scratch using HTML/CSS and then use regular javascript events
to change the visible layers of the map.  Just a quick example:

<script type="text/javascript">
var activeLayer = null;
function changeLayer()
{
   var layer = map.getLayersByName(this.value)[0];
   if(activeLayer != null) {
     activeLayer.setVisibility(false);
   }
   layer.setVisibility(true);
   activeLayer = layer;
}
</script>

<select onchange="changeLayer()">
<option value="layer1">Layer 1</option>
<option value="layer2">Layer 2</option>
<option value="layer3">Layer 3</option>
</select>

On Mon, Nov 28, 2011 at 10:14 AM, Aditya Kumar <paglacontact at yahoo.com>wrote:

> Dear Users,
>   I have a very big list of layers so instead of putting them in radio
> buttons and making the layer switcher to look ugly I want to put the layer
> list in a drop down box.
>
>
> Please help me in doing so!
>
>
> Aditya Kumar
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/Layers-in-drop-down-tp7039059p7039059.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111128/090359a6/attachment.html


More information about the Users mailing list