Thats It!<br><br>Thanks Andreas!<br><br><div class="gmail_quote">On Wed, Jul 1, 2009 at 6:11 PM, Andreas Hocevar <span dir="ltr"><<a href="mailto:ahocevar@opengeo.org">ahocevar@opengeo.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<div><div></div><div class="h5"><br>
On Wed, Jul 1, 2009 at 9:08 PM, Paul james<<a href="mailto:pauljame@gmail.com">pauljame@gmail.com</a>> wrote:<br>
> I have that layer on Openlayers :<br>
><br>
> var _layer = new OpenLayers.Layer.MapServer(<br>
> "PointLayer",<br>
> _cgi,<br>
> {<br>
> map: _mapfile,<br>
> singleTile: true,<br>
> layers: ['Layer1', 'Layer2', 'Layer3'],<br>
> transparent: "true",<br>
> format: "image/png"<br>
> },<br>
> );<br>
><br>
> If I use setVisibility on PointLayer, Layer1, 2 and 3 are turned ON...<br>
> How Can I turn on/off Layer1,Layer2,Layer3 individually on javascript?<br>
<br>
</div></div>Many ways to do that, no big deal. How 'bout<br>
<br>
var _layer = new OpenLayers.Layer.WMS(<br>
<div class="im"> "PointLayer",<br>
_cgi,<br>
{<br>
map: _mapfile,<br>
singleTile: true,<br>
layers: ['Layer1', 'Layer2', 'Layer3'],<br>
transparent: true,<br>
</div> format: 'image/png',<br>
initialize: function(name, url, params, options) {<br>
this.layerMap = {};<br>
var layer;<br>
for(var i=0; i<params.layers.length; ++i) {<br>
layer = params.layers[i];<br>
this.layerMap[layer] = true;<br>
}<br>
OpenLayers.Layer.WMS.prototype.initialize.apply(this, arguments);<br>
},<br>
setLayerVisibility: function(layer, visibility) {<br>
this.layerMap[layer] = visibility;<br>
var layers = [];<br>
for(var l in this.layerMap) {<br>
this.layerMap[l] && layers.push(l);<br>
}<br>
this.mergeNewParams({"LAYERS": layers});<br>
}<br>
}<br>
);<br>
<br>
Now you can e.g. use _layer.setLayerVisibility('Layer1', false) to<br>
turn off Layer1. This would probably also work with Layer.MapServer,<br>
but I have never used that, and MapServer supports Layer.WMS as well.<br>
<br>
Regards,<br>
Andreas.<br>
<br>
><br>
> Paul<br>
><br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
> <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Andreas Hocevar<br>
OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
Expert service straight from the developers.<br>
</font></blockquote></div><br>