-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Got some ideas for further GeoJson functionality.
Leaflet's GeoJson class has several keys in its callback that we're already utilizing to some extent.
Leaflet docs
One that is available, but which we're not yet using, is filter. It wants a function that will return a boolean for each feature in the GeoJson.
An idea I had, that I thought might be useful, would be to utilize this filtering after we've loaded the GeoJson into the browser. Perhaps most significant would be allowing to filter on or off features that have a value in their properties. This would be most useful for some kind of ordinal/discrete data that can be grouped together into a Set - not so much for quantitative data field where properties will have a unique value.
Unfortunately, filter is not available as a normal class method - it's only available in the GeoJson callback. This means that to redraw, the original L.geoJson object needs to be removed from the map and readded, with a new filter subset in the callback. This isn't optimal, but would allow us to do some more dynamic display methods, for instances when it might not make sense to add an entire separate layer to the LayerControl.
Here's a fiddle I made as a little use case scenario. It looks a more complex than our use case would be, since I'm loading the GeoJson asynchronously with a fetch call.
Let me know what you think - if it's feasible and worth spending time to try and incorporate, or outside the scope of the project.