I am trying to get a dynamically zooming mapbox plot, but it would be much easier to write a function for this if there was some way to access the full range of lat and lon that is being displayed at a given zoom.
This is all for the basic projection, I am not well versed in the geometry of spheres transposed to rectangles, so please allow for any misconceptions I have but,
e.g. I set a plot to zoom at 4, what is the range of this plots lat and lon?
If I set it to 3, then what is the range?
If there are any accessible attributes relating to the full display of the mapbox at a given zoom level that I could pull, e.g. Layout.mapbox.max_lat or Layout.mapbox.min_lon – something like that would be immensely useful.
It looks like Mapboxes inherently have a ‘bounds’ property for latitude and longitude but how can these be accessed from a plotly Scattermapbox instance?
which isn’t a great description. I don’t know if there’s a simple relationship between zoom level and longitude and latitude range. The viewbox size might have to be considered.
I think something like this might do the trick:
var gd = document.getElementById('graph')
Plotly.newPlot(gd, data, layout).then(() => {
var bounds = gd._fullLayout.mapbox._subplot.map.fitBounds
})