在Google Places API搜索中包含多种类型

2024-06-25 22:47:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用Python搜索googleplacesapi来获得多个类型的位置的结果,但是我得到的结果只是第一种类型的结果,即TYPE_RESTAURANT。在

google_places = GooglePlaces(API_KEY)
query_result = google_places.nearby_search(
    lat_lng={'lat' : -35.28346, 'lng' : 149.12807}, 
    radius=5000,
    types=[types.TYPE_RESTAURANT] or [types.TYPE_CAFE] or 
          [types.TYPE_BAR])

但是,我需要这三种类型的结果。我是不是做错了什么?在


Tags: orkeyapi类型typegooglequeryrestaurant
1条回答
网友
1楼 · 发布于 2024-06-25 22:47:29

如果您查看placesapi的官方文档,您将找到以下类型参数语句

type — Restricts the results to places matching the specified type. Only one type may be specified (if more than one type is provided, all types following the first entry are ignored). See the list of supported types.

来源:https://developers.google.com/places/web-service/search#PlaceSearchRequests

这意味着您必须发送多个查询来组合多个类型结果。在

相关问题 更多 >