【发布时间】:2020-06-22 15:28:52
【问题描述】:
数据是从 Google 表格的两列中提取的:
latitude = list(map(float, wks.col_values(3)[1:]))
longitude = list(map(float, wks.col_values(4)[1:]))
以下是创建地图的代码:
gmap = gmplot.GoogleMapPlotter(33.204345, -71.67478, 14, apikey="")
gmap.heatmap(latitude, longitude) #this works
gmap.marker(latitude, longitude, color='cornflowerblue')
gmap.draw("test55.html")
gmap.heatmap 工作得非常好....但是,gmap.marker 根本不起作用并产生以下错误:
TypeError: must be real number, not list
为什么 gmap 标记不接受我的坐标? :|
【问题讨论】:
-
marker()方法需要一个坐标对,而不是坐标列表。如果您想为每个点添加一个标记,则需要循环调用它。 -
又是这个。 TypeError:必须是实数,而不是列表。知道怎么做吗?我将在上面的编辑中添加我的尝试。
-
那个编辑应该做什么?您刚刚重新创建了两个浮动列表,它们与您已经拥有的两个浮动列表相同。你需要做的是
gmap.marker(latitude[0], longitude[0])。 -
这行得通!谢谢你。知道如何让它遍历每个电子表格条目吗?例如: gmap.marker(latitude[0], longitude[0], title="test") gmap.marker(latitude[1], longitude[1], title=elementfromcolumn5) gmap.marker(latitude[2],经度[2],title=elementfromcolumn5)
-
知道了:for x in range(0, 3): gmap.marker(latitude[x], longitude[x], title=boxnumber[x]) 编辑:如果你想回复你之前回答的问题,我会给你信用。再次感谢您!
标签: python python-3.x data-structures coordinates gmplot