After failing with the Holoviews-Datashader-Dash angle for my “display a tiff on a map with tooltip”, I started to implement it without Holoviews. To do that, I need to have the bounding box of the map, and from there I can hopefully create the appropriate image and serve it.
For this, theoretically I should use the RelyoutData. There is even a showcase, see first example here: https://dash.plotly.com/interactive-graphing. I’ve tried, and it works similarly with scatter mapbox too, so that’s great. But the problem, that I only get the detailed information when the user pans the map. In that case I get something like this:
{
"mapbox.center": {
"lon": 35.97214172702286,
"lat": -13.525062504454326
},
"mapbox.zoom": 5,
"mapbox.bearing": 0,
"mapbox.pitch": 0,
"mapbox._derived": {
"coordinates": [
[
29.380344852023114,
-6.388197039267411
],
[
42.563938602023484,
-6.388197039267411
],
[
42.563938602023484,
-20.454564833837253
],
[
29.380344852023114,
-20.454564833837253
]
]
}
}
But without any user interactions I just get this:
{
"autosize": true
}
If the user doesn’t pan just zooms, I get this:
{
"mapbox.zoom": 5.25
}
Now of course this is extremely useless as we are talking about a responsively sized map in a web application so of course I have no idea of the size of the map, so I have no clues about the initial bounding box.
So my questions:
- Is there a way to get the same detailed values on page load as on user pan? (I’ve searched for it everywhere with no luck so far.)
- Is there a way to trigger automatically a pan action on page load? I would be fine with a tiny pan, but I did not find a way to do it. (I’m not talking about changing the “center” of the Figure, as that changes the default position of the map too, and that’s exactly the problem that I don’t get detailed information if the map is on the default values.)
- If all of this is impossible (would be weird, as why would it have this functionality if there is no way to use it), what would be the best way to calculate an assumed bounding box if we only know the zoom (which is hardcoded at first and got the update value if the user zoomed) and a maximum width/height of the mapbox in px? (I’m thinking that in that case I would be able to generate a bit bigger images than needed to be sure to cover the visible area.)
Thanks!