map: Add a button to set the state of all children of a LayerGroup
This commit is contained in:
parent
3b1ba37435
commit
c5cf330238
15
src/map.js
15
src/map.js
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user