<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Jan,<div><br></div><div>the Map object has a function called&nbsp;getLayersByName which should help you in this case.</div><div><br></div><div>Best regards,</div><div>Bart</div><div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>--&nbsp;<br>Bart van den Eijnden<br>OpenGeo -&nbsp;<a href="http://opengeo.org/">http://opengeo.org</a><br>Expert service straight from the developers.</div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On Feb 18, 2011, at 10:47 AM, Jan Tappenbeck wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Am 18.02.2011 10:09, schrieb Dominik Mikiewicz:<br><blockquote type="cite">Map.layers[i].setVisibility(true);<br></blockquote><blockquote type="cite">Map.layers[i].redraw();<br></blockquote><br>hi !<br><br>but i search an alternative-way so set the visibilty to the layer by the name - not the index i ?!?!??!<br><br>regards Jan :-)<br><br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">-----Original Message-----<br></blockquote><blockquote type="cite">From: <a href="mailto:openlayers-users-bounces@lists.osgeo.org">openlayers-users-bounces@lists.osgeo.org</a><br></blockquote><blockquote type="cite">[mailto:openlayers-users-bounces@lists.osgeo.org] On Behalf Of Jan<br></blockquote><blockquote type="cite">Tappenbeck<br></blockquote><blockquote type="cite">Sent: Friday, February 18, 2011 8:42 AM<br></blockquote><blockquote type="cite">To: <a href="mailto:users@openlayers.org">users@openlayers.org</a><br></blockquote><blockquote type="cite">Subject: [OpenLayers-Users] Controll the Layervisibility by code<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;hi !<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">it is possible to define the visibility of a layer in the moment of<br></blockquote><blockquote type="cite">definition like<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;map.addLayer(new OpenLayers.Layer.OSM.Toolserver('osm-labels-en',<br></blockquote><blockquote type="cite">{isBaseLayer: false, visibility: true}));<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">but is it possible to control the visibility to a later time by code ??<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">i found following example:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">for(var i=0;i&lt;map.layers.length;i++)<br></blockquote><blockquote type="cite">{ &nbsp;&nbsp;&nbsp;Msg += map.layers[i].name + " :: " + map.layers[i].visibility + "\r\n";<br></blockquote><blockquote type="cite">}<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">but how to define the status exactly to a layer-variable-name? [i] is not a<br></blockquote><blockquote type="cite">name ?!?!?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">regards Jan :-)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">Users mailing list<br></blockquote><blockquote type="cite"><a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br></blockquote><blockquote type="cite"><a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br></blockquote><br><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>http://lists.osgeo.org/mailman/listinfo/openlayers-users<br></div></blockquote></div><br></div></body></html>