map: Add a button to set the state of all children of a LayerGroup

This commit is contained in:
Adam Goldsmith 2018-08-09 20:20:03 -04:00
parent 3b1ba37435
commit c5cf330238

View File

@ -227,7 +227,22 @@ function render_layer_toggles(event) {
input.type = 'checkbox';
input.className = "expand";
label.appendChild(document.createElement('span'));
layer_toggle(layer, label); // whole LayerGroup
let child_toggle_element = label.appendChild(
document.createElement('input'));
child_toggle_element.type = 'checkbox';
child_toggle_element.checked = true;
child_toggle_element.addEventListener('click', event => {
console.log("test");
layer.getLayers().forEach(subLayer => {
subLayer.setVisible(event.target.checked);
subLayer.toggle_element.querySelector("input").checked =
event.target.checked;
});
});
let container = label.appendChild(document.createElement('div'));
container.className = 'collapsible-content';
layer.getLayers().forEach(