I have a mapbox map that displays a number of points from a GEOJson source with several features and independent categories. I want to be able to filter by these features.
Ideally when I click on a checkbox filter only the relevant points should remain visible on the layer.
So I guess after a click on a checkbox the map points should all be cleared and the map should be redrawn with only the relevant points. For that I need to know
- how to loop over all active points after the click on the checkbox and kick all out all points that are not wanted
Or
- clear all the points from the map
- load/add only a filtered part of the points to the map
- refresh the map data.
All the examples I found on the mapbox page use different layers for the categories and toggle the visibility of these layers. This assumes that a point can only be in one category at a time. But in my case there are several categories that are independent from each other (similar to the categories "color", "shape", "weight", etc). So I need to filter the points individually.
Any idea how to tackle this?