[OpenLayers-Users] Controll the Layervisibility by code

Jan Tappenbeck osm at tappenbeck.net
Fri Feb 18 02:42:00 EST 2011



  hi !

it is possible to define the visibility of a layer in the moment of 
definition like

     map.addLayer(new OpenLayers.Layer.OSM.Toolserver('osm-labels-en', 
{isBaseLayer: false, visibility: true}));


but is it possible to control the visibility to a later time by code ??

i found following example:

for(var i=0;i<map.layers.length;i++)
{    Msg += map.layers[i].name + " :: " + map.layers[i].visibility + "\r\n";
}

but how to define the status exactly to a layer-variable-name? [i] is not a name ?!?!?



regards Jan :-)




More information about the Users mailing list