leaflet-list-markers
leaflet-list-markers copied to clipboard
Show/hide list markers on filtering with Layer Groups
Im using the native Leaflet filtering (Layer Groups and Layers Control): https://leafletjs.com/examples/layers-control/ When I hide/show the different groups, the marker list it's not updating. How can I achieve this? I've also tried this with the demo-project for this plugin - same results as in my project.
I've made a function that checks if each filter is checked of that helps:
let checkboxTest = document.querySelectorAll('.leaflet-control-layers-selector'); for(let i = 0; i < checkboxTest.length; i++) { checkboxTest[i].addEventListener('change', function(){ console.log(checkboxTest[i].parentElement.textContent + ' is: ' + checkboxTest[i].checked); }); }
Here is my Layer control: ` const overLayMap = { 'Group A': groupA, 'Group B': groupB, };
const filter = L.control.layers(null, overLayMap, {collapsed:false}).addTo(map);
`