I have polygons features on a Mapbox map. Their sizes vary a lot (some are big as streets, others are as little as a tree).
Each polygon has an a point feature on it (a circle) that acts as an handle to open a popup related to the polygon data.
But depending on the zoom level, the circle/point is sometimes bigger than the polygon itself; since the polygon "sticks" to the map while the circle size remains unchanged.
What I would like to achieve is to hide the polygon (and its handle) if the polygon size in pixels is smaller than the circle :
- when zoom changes
- get the size in pixels of a bouding box containing the polygon
- compare it to the size of the circle
- hide both of them if circle radius > polygon smaller side.
I think I'm capable of coding this, but then... how can I hide the features ?
There is a minzoom / maxzoom setting for sources and layers, but how can I achieve this per-feature ?
Thanks!