Fit bounds not fitting to provided points
this-josh opened this issue · comments
Describe the bug
I have a plot which I'd like to export as png
so I'm using the _to_png
feature. Ideally I'd like a zoom level of around 4.5 - my plot should cover from Madrid to St.Petersburg (roughly) - but I cannot provide this. When I provide bounds the image I get out doesn't seem to be obeying them.
I appreciate this is likely a function of dynamic window resizing, but exporting as png
should be able to adhere to the provided bounds despite the png
support being via selenium.
To Reproduce
import folium
m = folium.Map()
sw = [38, -3]
ne = [60, 31]
m.fit_bounds([sw, ne])
m.save("map.html")
import io
from PIL import Image
img_data = m._to_png(1)
img = Image.open(io.BytesIO(img_data))
img.save('map_plot.png')
Expected behavior
A png
file contained within the provided bounds
Environment (please complete the following information):
- Browser [e.g. chrome, firefox] Chromium based
- Jupyter Notebook or html files? HTML and jupyer
- Python version (check it with
import sys; print(sys.version_info)
) 3.12.1 - folium version (check it with
import folium; print(folium.__version__)
) 0.15.1 - branca version (check it with
import branca; print(branca.__version__)
) 0.7.1