79433946

Date: 2025-02-12 17:35:50
Score: 1
Natty:
Report link

Okay so, I cannot say exactly what the problem was. But I took a good hard look at all of my filtering functions and they did seem a little convoluted to me. What might have been problematic is that MarkerCluster apparently filters out everything outside of the current map view, and I was also doing that.

I ended up adding another plugin, Leaflet.FeatureGroup.SubGroup, which I am now using to filter by categories. And for the list output in the HTML I loop through all markers currently visible and remove the hidden class from the entries with the corresponding ids.

I also have a text input for filtering which originally prompted my more convoluted approach. Now I am doing it with another loop through the visible markers, hiding the ones that don’t match. This is definitely visible when moving or zooming the map, but it only takes half a second or so for some of the newly appearing markers to disappear again, and all the transitions are super smooth, so I think this is acceptable.

Thanks for your input everyone!

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (0.5): I cannot
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Anna Kleiner