[OpenLayers-Users] Re: Controll the Layervisibility by code

Bart van den Eijnden bartvde at opengeo.org
Fri Feb 18 04:51:30 EST 2011


Hi Jan,

the Map object has a function called getLayersByName which should help you in this case.

Best regards,
Bart

-- 
Bart van den Eijnden
OpenGeo - http://opengeo.org
Expert service straight from the developers.



On Feb 18, 2011, at 10:47 AM, Jan Tappenbeck wrote:

> Am 18.02.2011 10:09, schrieb Dominik Mikiewicz:
>> Map.layers[i].setVisibility(true);
>> Map.layers[i].redraw();
> 
> hi !
> 
> but i search an alternative-way so set the visibilty to the layer by the name - not the index i ?!?!??!
> 
> regards Jan :-)
> 
> 
>> 
>> -----Original Message-----
>> From: openlayers-users-bounces at lists.osgeo.org
>> [mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Jan
>> Tappenbeck
>> Sent: Friday, February 18, 2011 8:42 AM
>> To: users at openlayers.org
>> Subject: [OpenLayers-Users] Controll the Layervisibility by code
>> 
>> 
>> 
>>   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 :-)
>> 
>> 
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 
> 
> _______________________________________________
> 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/20110218/b1732560/attachment.html


More information about the Users mailing list