Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

fit_bounds seems to fail when multiple maps/cells are rendered in a notebook

未关闭
#2,080 8 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
jupyter-notebook, python

调研方向

将附加的 FitBoundsTest.txt 文件重命名为 .ipynb,并在 Jupyter 中使用多个地图运行它,在“restart kernel and run all”期间比较屏幕内和屏幕外的执行。检查单元格连续运行以及重新运行失败单元格时 fit_bounds 的渲染行为。所有复现的地图都能一致地适应其边界,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Describe the bug
Since about September of 2024 I've noticed that folium seems to sometimes fail to correctly "apply" fit_bounds to maps when multiple maps are rendered back-to-back. Manually running map generation cells a second time seems to cause the map to zoom/fit correctly. Have others experienced this?

To Reproduce
[update] I'm happy to report that I now have a concise notebook the reproduces this issue for me consistently.
FitBoundsTest.txt Rename as .ipynb

The issue seems to be related to whether the call to the map rendering function is on or off screen at the time it gets executed. In my browsers, calling "restart kernel and run all" on this notebook causes the notebook to scroll to the start of the last cell where I have some filler_text which fills the screen, yet the last call to test() is barely visible. If I don't scroll during the execution of the cells, once the run is complete, when I do scroll up almost always the first map has not "zoomed" (fit to bounds correctly),
Screenshot from 2025-01-16 08-13-15
Sometimes the second map is also not "zoomed" correctly, but always the third is. If I remove the filler text (or move it to the top) and restart and run all again, all 3 maps "zoom" correctly. Similarly, if I scroll up to the calls to test() while it is "running all", it also succeeds every time. And, if I manually re-run a single cell that failed to zoom correctly during run all, it then zooms correctly. I hope that helps find and fix the issue. Please let me know how I can be of more assistance.

Expected behavior
All maps correctly fit to bounds as expected.

Environment (please complete the following information):

Current setup, though I've seen it in other settings as well. I believe on windows.

  • Browser: Firefox and Chrome
  • Jupyter Notebook or html files? Jupyter
  • Python version: 3.11.8
  • folium version: 0.19.4
  • branca version: 0.8.1

Additional context
Never saw this before the end of September 2024, but now see it many places.

Possible solutions
?

folium is maintained by volunteers. Can you help making a fix for this issue?
Maybe

主要语言
Python
星标
7.4k
派生
2.3k
平均合并
17 小时 22 分钟
30 天内合并 PR
11

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python-visualization/folium 的其他 Issue

查看 python-visualization/folium 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。