[OpenLayers-Users] Dependent layers in overlay of LayerSwitcher
S.Reena
reena at indiamail.com
Sat Oct 11 04:19:01 EDT 2008
Hi,
I have made Overlay so that it consists on 7 layers..last three not being
shown in LayerSwitcher. I want that if I uncheck layer 2...layer 5 shud also
disappear from map same for layers (3,6) and (4,7). I modified the
LayerSwitcher like this:
updateMap: function() {
// set the newly selected base layer
for(var i=0; i < this.baseLayers.length; i++) {
var layerEntry = this.baseLayers[i];
if (layerEntry.inputElem.checked) {
this.map.setBaseLayer(layerEntry.layer, false);
}
}
// set the correct visibilities for the overlays
for(var i=0; i < this.dataLayers.length; i++) {
// alert(i);
var layerEntry = this.dataLayers[i];
layerEntry.layer.setVisibility(layerEntry.inputElem.checked);
// Added By Reena
if((i==1)&& (layerEntry.layer.visibility==false))
{
var layerEntry1 = this.dataLayers[5];
layerEntry1.layer.setVisibility(false);
}
if((i==2)&& (layerEntry.layer.visibility==false))
{
var layerEntry1 = this.dataLayers[6];
layerEntry1.layer.setVisibility(false);
}
if ((i==3)&& (layerEntry.layer.visibility==false))
{
var layerEntry1 = this.dataLayers[7];
layerEntry1.layer.setVisibility(false);
}
}
},
..................
The problem is that if I dont show the last three layers in LayerSwitcher
...its not working ...but if I do then it is....the value of 'i' is not
incrementing till the last layer but to the displayed layer only.
The layers I have made is like this
--------------------------------------
wms[5] = new OpenLayers.Layer.WMS.Untiled(
"
label","http://gis.rtbi-iitm.in/cgi-bin/mapserv?map=/var/www/html/v1/mapfile/dist_label.map",
{'layers':
"TN_District",'transparent':"true"},{'displayInLayerSwitcher':true},{'isBaseLayer':false});
wms[6] = new OpenLayers.Layer.WMS.Untiled(
"
label","http://gis.rtbi-iitm.in/cgi-bin/mapserv?map=/var/www/html/v1/mapfile/taluk_label.map",
{'layers':
"Tnd_Taluk",'transparent':"true"},{'displayInLayerSwitcher':true},{'isBaseLayer':false});
wms[7] = new OpenLayers.Layer.WMS.Untiled(
"
label","http://gis.rtbi-iitm.in/cgi-bin/mapserv?map=/var/www/html/v1/mapfile/vill_label.map",
{'layers':"Tnd_Village",'transparent':"true"},{'displayInLayerSwitcher':true},{'isBaseLayer':false});
-------------------------------------------
Can any1 help?
Cheers,
Reena.
--
View this message in context: http://www.nabble.com/Dependent-layers-in-overlay-of-LayerSwitcher-tp19930616p19930616.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list