我有59个位置,我需要查找这些位置之间的距离以及行进该距离所花费的时间。
我有Google Cloud Platform免费试用版的API密钥,并且在Stack Overflow上找到了以下代码:
# importing googlemaps module
import googlemaps
# Requires API key
gmaps = googlemaps.Client(key='APIKEY')
# Requires cities name
my_dist = gmaps.distance_matrix('Delhi','Mumbai')['rows'][0]['elements'][0]
# Printing the result
print(my_dist)
返回字典
{'distance': {'text': '1,415 km', 'value': 1415489}, 'duration': {'text': '1 day 0 hours', 'value': 87575}, 'status': 'OK'}
但是我仍然在围绕如何输入所有位置以获取两个矩阵(之间的距离/之间的时间)