I’ve been experimenting with the OSM tile server (https://tile.openstreetmap.org/) and have been converting lat/long to tile coordinates for embedding the tile into a web page.
However, what I actually need to do is find the ‘best’ tile for a given bounded box. I currently have four coords for the min and max lat and long. What I would like to get is the most ‘zoomed in’ tile that includes these coordinates.
This may look like:
- Calculate the average coordinate for the centre of the tile
- Find the right zoom level to include all bbox coordinates
Is this possible? (I’m working in JS but all answers gratefully received)