I'm trying to build a function to dynamically filter markers on the map. Check a value in in each feature.properties.value against some criteria. I'm wondering what to do on each filtering event:
- Just remove/clear the whole geojsonlayer (all markers) and update (getJSON) new markers again where I check them against a filter criteria before I add them to the geojson layer.
or
- Iterate through each layer in the geojson layer, check each layers properties against a criteria, remove those that does not match and the then update (getJSON) new markers and check them against the criteria.
or
- Update (getJSON) and run a loop over each feature and split them up in different layergroups by criteria from the start. Then hide/show (?) each layergroup if they match the criteria.
Do you know any other ways to do it? How would you do it? Thinking of scaling/performance..
(I'm also going to store each marker id in an array and check to avoid adding duplicates.)