Skip to content

Fit bounds not fitting to provided points  #1877

Description

@this-josh

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions