【问题标题】:Google Places Autocomplete API 'types' parameter only works with establishment?Google Places Autocomplete API“类型”参数仅适用于建立?
【发布时间】:2017-08-13 23:58:15
【问题描述】:

我尝试在我的应用程序中使用 Google Place 的自动完成 API,但在将结果过滤为特定类型(即 restaurant)时遇到问题。

每当我将types 参数更改为establishment 以外的其他参数时,我都会收到INVALID_REQUEST 响应。

但是,当我对附近的所有餐馆进行标准搜索时,显示的结果与相同的自动填充结果匹配。

示例:Applebee's at 555 Saratoga Avenue, San Jose, CA 出现在我的 nearby 搜索和我的 autocomplete 搜索中,但在 autocomplete API 响应中只有 establishment 类型,而它在标准搜索 API 响应中有 restaurant

还有其他人遇到此问题或知道解决方法吗? API Docs 听起来好像所有有效类型都应该在自动完成 API 请求中是可接受的。

这是我使用type=restaurant 的网址,但总是失败:

https://maps.googleapis.com/maps/api/place/autocomplete/json?types=restaurant&input=applebee&radius=48280.2&rankby=distance&key=MY_API_KEY&location=37.33233141,-122.0312186

这是使用type=establishment 的有效网址:

https://maps.googleapis.com/maps/api/place/autocomplete/json?types=establishment&input=applebee&radius=48280.2&rankby=distance&key= MY_API_KEY&location=37.33233141,-122.0312186

【问题讨论】:

    标签: types autocomplete google-places-api


    【解决方案1】:

    可用于自动完成的类型比可用于搜索的类型更受限制。 “餐厅”不是自动完成的有效地点类型。有效的类型是:

    • 地理编码
    • 建立
    • 地址
    • (地区)
    • (城市)

    有关更多信息,请参阅文档中的 Place Types

    【讨论】:

    • 这是正确的(不幸的是)。希望有一种方法可以使用任何类型,但猜不到。谢谢。
    • regions 真的有用吗?我无法通过 regions 类型提出请求
    • 对不起。它是“(地区)”,而不是“地区”。我已经更新了答案。
    • (regions) 对我也不起作用,没有显示任何结果。
    【解决方案2】:

    是的 restaurant 类型参数在/place/autocomplete/json 中不起作用

    如果你想找到“餐厅”place/textsearch/json?

    添加后搜索文字+

    示例 1:

    https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurant+applebee&key={API_KEY}
    

    示例 2:

    https://maps.googleapis.com/maps/api/place/radarsearch/json?location=48.859294,2.347589&radius=5000&type=cafe&keyword=vegetarian&key=YOUR_API_KEY
    

    多类型使用types=food|restaurant

    了解更多信息 https://developers.google.com/places/web-service/search

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-08
      • 1970-01-01
      • 2019-01-27
      • 2020-05-27
      • 2016-05-30
      • 2018-11-09
      • 2017-01-23
      • 1970-01-01
      相关资源
      最近更新 更多