python显示地图与谷歌地图

时间:2016-03-04 14:08:22

标签: python google-maps

我找到了一个googlemaps软件包来从python访问谷歌地图,但没有找到任何演示以在python代码中显示结果。

例如:

gmaps = googlemaps.Client(key='Add Your Key here')

# Geocoding an address
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')

# Look up an address with reverse geocoding
reverse_geocode_result = gmaps.reverse_geocode((40.714224, -73.961452))

# Request directions via public transit
now = datetime.now()
directions_result = gmaps.directions("Sydney Town Hall",
                                     "Parramatta, NSW",
                                     mode="transit",
                                     departure_time=now)

我可以将directions_result打印到控制台,但不知道如何以图形模式显示地图。如何在python中将搜索结果显示为地图?

1 个答案:

答案 0 :(得分:16)

因为 googlemaps 包仅适用于数据/响应API。

有关更多信息,请阅读本教程(编写JS地图和数据分析):https://github.com/invisibleroads/invisibleroads-tutorials/blob/master/geodjango-googlemaps-build.rst

要在Google地图上绘制数据,请使用:https://github.com/vgm64/gmplot