I have an accordion style section that contains content panes with layers inside them for the user to turn on and off
As seen below there are 5 content panes
I am building a layer list that has checkboxes built on the fly with JavaScript.
I am using this on each FeatureLayer to determine which one it goes into:
legendLayers4.push({ layer: RailYards, title: 'Rail Yards' });
I added a button to the each of their content panes to be used to check all boxes or uncheck all boxes
What I am trying to do now is turn on all layers in that specific content pane by clicking the BUTTON or turning them all off by clicking the same BUTTON
I can handle all the little stuff but just cant see to get control of them in Javascript....
How do I test each checkbox...I can return their Layer title and Layer ID etc but can seem to be able to get the actual checkbox reference to test if it is checked or not...If I can get that far I can handle the button etc
I am trying to get to the individual checkboxes in document.getElementById("FeaturesButton").onclick = function () {
You can see below that I am looping trough the legendLayers4 and creating a checkbox and label for each checkbox to be created.
<div id="IDAccordionPaneLayers" data-dojo-type="dijit.layout.AccordionContainer" style="color:black; height:50%; width:90%;">
<div id="idLayers4" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="title:'Features'" selected="true" >
<button type="button" id="FeaturesButton" style="float: right;" >Click Me!</button>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="title:'Natural Disasters'">
<div id="toggle4" style="padding: 2px 2px; color:Black;"></div>
</div>
</div>
</div>
legendLayers4.push({ layer: RailYards, title: 'Rail Yards' });
arrayUtils.forEach(legendLayers4, function (layer) {
var layerName = layer.title;
var checkBox = new CheckBox({
name: "checkBox" + layer.layer.id,
value: layer.layer.id,
checked: layer.layer.visible
});
checkBox.on("change", function () {
var targetLayer = map.getLayer(this.value);
targetLayer.setVisibility(!targetLayer.visible);
this.checked = targetLayer.visible;
});
domConstruct.place(checkBox.domNode, dom.byId("toggle4"), "after");
var checkLabel = domConstruct.create('label', {
'for': checkBox.name,
innerHTML: layerName
}, checkBox.domNode, "after");
domConstruct.place("<br />", checkLabel, "after");
});
document.getElementById("FeaturesButton").onclick = function () {
arrayUtils.forEach(legendLayers4, function (layer) {
var layerName = layer.title;
var layerID = layer.layer.id;
var i;
for (i = 0; i < layerID.length; i++) {
alert(layerID);
}
});
};