首页 > 解决方案 > gmplot 标记在标记 256 点后不起作用

问题描述

我正在尝试用 gmplot 在地图上标记一堆点,并观察到在某个点之后它会停止标记并清除所有先前标记的点。我调试了 gmplot.py 模块,发现当点数组的长度超过 256 时,会发生这种情况而没有给出任何错误和警告。

self.points = [] on gmplot.py

由于我对 Python 和 OOP 概念非常陌生,有没有办法覆盖它并标记超过 256 分?

标签: python-3.xgmplot

解决方案


您使用的是gmplot.GoogleMapPlotter.Scatter还是gmplot.GoogleMapPlotter.Marker。我使用了其中任何一个,并且能够为465我正在从事的项目获得积分。这可能是您的 API 密钥问题吗?

我的代码的部分片段

import gmplot
import pandas as pd
# df is the database with Lat, Lon and formataddress columns
# change to list, not sure you need to do this.  I think you can cycle through
# directly using iterrows.  I have not tried that though
latcollection=df['Lat'].tolist()
loncollection=df['Lon'].tolist()
addcollection=df['formataddress'].tolist()
# center map with the first co-ordinates
gmaps2 = gmplot.GoogleMapPlotter(latcollection[0],loncollection[0],13,apikey='yourKey')
for i in range(len(latcollection)):
    gmaps2.marker(latcollection[i],loncollection[i],color='#FF0000',c=None,title=str(i)+' '+ addcollection[i])
gmaps2.draw(newdir + r'\laplot_marker_full.html')                  

我可以将鼠标悬停在第 465 点上,因为我知道它的大致位置,并且我能够使用 获得标题str(464) <formataddress(464)>,因为我的数组是从 0 开始索引的

确保检查 GitHub 站点以修改 gmplot 文件,以防您使用 Windows。


推荐阅读