Using Mapbox GL JS 0.39.1, I set a filter on my layer:
map.setFilter('myLayer', ['!=', 'myKey', 'myValue'])
I cannot find a way to remove the filter. I would have thought there would be a map.removeFilter... function but have found nothing in the docs or in web searches. I could apply a fake filter (>'') so that it always matches but that seems inefficient. Surely there is a way to remove a filter.
EDIT: I have found that using the following code will achieve what I am trying to accomplish. Not sure if this is the recommended approach.
map.setFilter('myLayer');
The docs were just updated, personally I would recommend using
map.setFilter('myLayer', null)
as it's more explicit and in my opinion makes the code more readable. Though your approach of just map.setFilter('myLayer');
is also acceptable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With