Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fit bounds not fitting to provided points #1877

Open
this-josh opened this issue Feb 9, 2024 · 0 comments
Open

Fit bounds not fitting to provided points #1877

this-josh opened this issue Feb 9, 2024 · 0 comments

Comments

@this-josh
Copy link
Contributor

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant