Good day all,I have an application of 2 maps which requires 40 + layers per map to be toggled on and off for a time series comaparison. I have seperated the layers into groups of checkboxes (page design, trying to fit it all in) and have done this grouping the layers using .push to load layers into lists. To create the checkbox groups I use the following code:dojo.connect(map1,'onLayersAddResult',function(results){
//add check boxes Map 1 Layers
dojo.forEach(layersList1,function(layer){
var layerName = layer.title;
var checkBox = new dijit.form.CheckBox({
name: "checkBox" + layer.layer.id,
value: layer.layer.id,
checked: layer.layer.visible,
onChange: function(evt) {
var clayer = map1.getLayer(this.value);
clayer.setVisibility(!clayer.visible);
this.checked = clayer.visible;
}
});
//add the check box and label to the toc Map 1 Layers
dojo.place(checkBox.domNode,dojo.byId("Map1_layers"),"after");
var checkLabel = dojo.create('label',{'for':checkBox.name, innerHTML:layerName},checkBox.domNode,"after");
dojo.place("<br />",checkLabel,"after");
});
});
What I need to do is only show a few of the layers when the page loads. I have been able to accomplish this by setting the visibilty of the layers to true/false in the layer constructor but this interupts the way the checkbox functions. When I check a layer to make it visible "only" the first layer in the list toggles and not the associated layer with the checkbox.Below is an example of my layer lists and layer constructor:layersList1.push({layer:Sept09_fl_1m1,title:"Sept 2009"});
layersList1.push({layer:Dec09_fl_2m1,title:'Dec 2009'});
layersList1.push({layer:Mar10_fl_3m1,title:'Mar 2010'});
layersList1.push({layer:June10_fl_4m1,title:'June 2010'});
var Landsat_2010_m1 = new esri.layers.ArcGISDynamicMapServiceLayer("http://sirgis2/ArcGIS/rest/services/CentralWest/Landsat_Callide/MapServer");
Landsat_2010_m1.setVisibleLayers([2]);
thanks for any assistancecheers ~ Rory