如何检索多个地方(placeids)的Google地方详细信息

dc1*_*c10 14 google-maps google-places-api

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

https://maps.googleapis.com/maps/api/place/details/json?placeid=[ArrayInsteadOfJustOnePlaceId]
Run Code Online (Sandbox Code Playgroud)

文档没有提到有关解决多个地方的任何事情.

谷歌地方文件

Gae*_*ael 2

您无法通过单个请求来完成此操作。您必须迭代地点 ID 列表并为每个地点进行调用。

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

pip install python-google-places
Run Code Online (Sandbox Code Playgroud)
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

Run Code Online (Sandbox Code Playgroud)