'mapbox : calculate the optimal zoom level to distinguish two overlapping markers (knowing their size and the distance between them)

When clicking on a marker, I would like to zoom my map enough to distinguish it from the other markers around it.

My marker is 10x10 pixels. Distance to the nearest marker is 0.02km. I would like a margin of 5 pixels between them.

How could I compute the required zoom based on those parameters ?

Thanks !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source