python用googlemaps显示地图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35798126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 16:57:50  来源:igfitidea点击:

python display map with googlemaps

pythongoogle-maps

提问by beetlej

I found a googlemapspackage to access google map from python,but didn't find any demo to show the result in python code.

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

For example:

例如:

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)

I can print the directions_result to console but don't know how to show the map in graphic mode. How to show the search result as a map in python?

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

回答by Maciej A. Czyzewski

Because googlemapspackage is only for data/responses API.

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



For more information read this tutorial (writing JS map & data analysis): https://github.com/invisibleroads/invisibleroads-tutorials/blob/master/geodjango-googlemaps-build.rst

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



For plotting data on google maps use: https://github.com/vgm64/gmplot

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