Python gmplot 'centerLat' 未定义

标签 python google-maps matplotlib visualization

我正在尝试用Python从谷歌地图绘制一个简单的 map 。我使用 gmplot 并按照 https://pypi.python.org/pypi/gmplot/1.0.5 上的示例进行操作

下面的代码是

Python 2.7.11::Anaconda 2.4.1(64 位) 和

Ipython版本4.0.1

import gmplot
gmap = gmplot.GoogleMapPlotter(37.428, -122.145, 16)

我收到以下错误

    ---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-d299e195e0e8> in <module>()
      1 import gmplot
      2 
----> 3 gmap = gmplot.GoogleMapPlotter(37.428, -122.145, 16)

/home/sebastia/Documents/gmplot-1.0.5/gmplot/gmplot.pyc in __init__(self, center_lat, center_lng, zoom)
     17 
     18     def __init__(self, center_lat, center_lng, zoom):
---> 19         self.center = (float(centerLat), float(centerLng))
     20         self.zoom = int(zoom)
     21         self.grids = None

NameError: global name 'centerLat' is not defined

我知道变量 center_lat 被初始化而不是 centerLat,这就是导致问题的原因。我对吗?如果是这样,我该如何解决这个问题?在 python 中绘制谷歌地图的最佳模块是什么?

提前致谢

最佳答案

有一个错误(变量名称错误,请查看第 18 行):

  • centerLat 应为 center_lat
  • centerLng 应为 center_lng

引用: https://github.com/vgm64/gmplot/commit/744ab878a17d31dc95bec3e31e9fac54fb6f216b

解决方案:
更新至版本gmplot-1.1.0

关于Python gmplot 'centerLat' 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36248257/

相关文章:

python - Python 3.x 中的绘图

python - 如果键和值与其他字典不匹配,则从字典列表中删除字典

python - 返回字典 Python 中所有值的总和

python - 为什么 torch.from_numpy 需要不同的字节顺序而 matplotlib 不需要?

ios - 如何在 gmsmap View 上闪烁 gms 标记

javascript - 获取错误 "Error: $injector:modulerr Module Error"

python - 有没有办法使用 matplotlib 在饼图中仅显示某些百分比?

python - 如何在sklearn中的RandomForest中的不同迭代中获得相同的结果

python Pandas : Does 'loc' and 'iloc' stand for anything?

android - 在谷歌地图 fragment 中显示当前位置