首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >get_bounds()返回[[None,None],[None,None]]

get_bounds()返回[[None,None],[None,None]]
EN

Stack Overflow用户
提问于 2019-04-03 13:03:57
回答 2查看 571关注 0票数 0

使用以下代码,我希望获得可见地图的经纬度对:

代码语言:javascript
复制
import folium

testmap = folium.Map(location=[-23.52, 115.5]
                  , zoom_start=7
                  , prefer_canvas=True
                  )

testmap.get_bounds()

相反,我得到的是:

代码语言:javascript
复制
[[None, None], [None, None]]

我做错了什么?我正在使用主分支的Folium,如果这有助于解决这个问题的话。

EN

回答 2

Stack Overflow用户

发布于 2019-04-03 13:17:39

看看这是否对你有帮助:https://nbviewer.jupyter.org/gist/ocefpaf/815b267199a1c1d4ac43f37cf8b8d4a8

这为您提供了如何正确使用get_bounds的示例

票数 0
EN

Stack Overflow用户

发布于 2020-08-05 16:18:17

我也遇到了这个问题,我没有解决方案,但我知道在查看get_bounds()函数的实现时会发生什么。

代码语言:javascript
复制
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]]

因此,首先计算map本身的边界(返回None值),然后计算子节点的边界。由于在您的示例中没有子级,因此get_bounds()函数返回[[None, None], [None, None]]

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55487424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档