Black Lives Matter. Please consider donating to Black Girls Code today.

Scattermap performance: Only load data within bounding box or smooth at higher zooms

Hello community!

I am rendering choropleth plots with scattermapbox with quite a high resolution. Obviously, this high resolution is needed only at large zooms. Yet at smaller zooms, despite not benefiting from the resolution, the plot remains quite slow.
Is there any optimisation possible?

I am thinking of three solutions which all are not practical:

  1. obtain the bounding box of the map (I couldn’t find any way to get them, I think this is not possible) and only plot whatever is inside the bounding box
  2. re-mesh the layers accordingly to the zoom to have less element to plot: this will prohibit reaching larger zoom if 1) cannot be done.
  3. transform the grid into a heatmap, prohibiting the user to understand the limitation of the model by not showing the grid.

Is there any other way to do it?