python-3.x - get_bounds() 返回 [[None, None], [None, None]]
问题描述
使用以下代码,我希望获得可见地图角的纬度/经度对:
import folium
testmap = folium.Map(location=[-23.52, 115.5]
, zoom_start=7
, prefer_canvas=True
)
testmap.get_bounds()
相反,我得到:
[[None, None], [None, None]]
我做错了什么?我正在使用来自 master 分支的 Folium,如果这有助于解决这个问题。
解决方案
我也遇到了这个问题,我没有解决方案,但我知道在查看get_bounds()
函数的实现时发生了什么。
def get_bounds(self):
"""Computes the bounds of the object and all it's children
in the form [[lat_min, lon_min], [lat_max, lon_max]].
"""
bounds = self._get_self_bounds()
for child in self._children.values():
child_bounds = child.get_bounds()
def _get_self_bounds(self):
"""Computes the bounds of the object itself (not including it's children)
in the form [[lat_min, lon_min], [lat_max, lon_max]]
"""
return [[None, None], [None, None]]
因此,首先计算地图本身的边界(返回 None 值),然后计算孩子的边界。由于在您的示例中没有子级,因此该get_bounds()
函数返回[[None, None], [None, None]]
.
推荐阅读
- google-chrome - Chrome 开发工具不会触发媒体查询?
- security - 在经典 ASP 中将 httponly 标志设置为双参数 cookie
- python - Spark:spark.sql 和 sqlCtx.sql 有什么区别
- python - 使用 Python 在 Anaconda 中缺少解析器库 (lxml)
- java - Java...嵌套循环优化
- sql - SQL Sever 2012+ 返回非字母数字字符,不包括空格
- symfony - 如何自定义学说默认 CRUD 生成器视图
- javascript - JsExceptions 的本质是什么以及如何处理?
- sql-server - 两个日期之间的 SQL,其中日期用整数表示
- delphi - 当节点获得焦点时,哪个选项会影响 TVirtualStringTree 滚动到视图中?