gpt4 book ai didi

google-maps - 如何检索多个地点的谷歌地点详细信息(placeids)

转载 作者:行者123 更新时间:2023-12-03 22:46:00 25 4
gpt4 key购买 nike

是否可以检索多个地点的地点详细信息?

https://maps.googleapis.com/maps/api/place/details/json?placeid=[ArrayInsteadOfJustOnePlaceId]

该文档没有提及有关解决多个位置的任何内容。

google places doc

最佳答案

你不能在一个请求中做到这一点。
您必须遍历一个地点 ID 列表并为每个地点进行调用。

这是使用此 python 包装器执行此操作的示例代码:
/slimkrazy/python-google-places

pip install python-google-places

from googleplaces import GooglePlaces, GooglePlacesAttributeError, GooglePlacesError

GOOGLE_API_KEY = 'AIzaSyDRcaVMH1F_H3pIbm1T-XXXXXXXXXXX'
GOOGLE_PLACE_IDS = [
"ChIJC4Wu9QmvthIRDmojjnJB6rA",
"ChIJuRFUv33Ew0cRk0JQb2xQOfs",
"ChIJ9yGYrIwd9kcRlV-tE8ixHpw"
]

def main():
google_places = GooglePlaces(GOOGLE_API_KEY)
for place_id in GOOGLE_PLACE_IDS:
try:
place = google_places.get_place(place_id)
print('{0} place_id has name {1}'.format(place_id, place.name))

except (GooglePlacesError, GooglePlacesAttributeError) as error_detail:
print('Google Returned an Error : {0} for Place ID : {1}'.format(error_detail, place_id))
pass

关于google-maps - 如何检索多个地点的谷歌地点详细信息(placeids),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37722531/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com