【问题标题】:autocomplete to return results within a radius自动完成以返回半径内的结果
【发布时间】:2019-10-29 05:02:36
【问题描述】:

在我的谷歌地图自动完成服务器端查询中,我试图返回纬度和经度附近或附近的结果,到目前为止我已经尝试过

https://maps.googleapis.com/maps/api/place/autocomplete/json?key=<<KEY>>&types=geocode&sensor=true&language=en&location=40.64131109999999%2C-73.77813909999998&strictBounds=true&radius=10&input=london

WHERE 40.64131109999999%2C-73.77813909999998 是 JFK - 约翰·F·肯尼迪国际机场的纬度和经度。

但是当搜索字符串是 london 时,结果仍然显示。知道如何将结果限制在某个半径/边界或国家范围内吗?谢谢

【问题讨论】:

  • strictBounds 不正确。
  • @MrUpsidown 我该怎么办?或者我要添加什么?
  • 阅读文档!它是你最好的朋友。 URL 参数区分大小写。

标签: google-maps google-maps-api-3 google-places-api


【解决方案1】:

以下是我对您的 URL 请求的发现:

  • 您已包含strictBounds=true,这是不正确的,因为参数区分大小写,因此将在请求中省略。它应该是strictbounds
  • 您也不需要=true,因为添加参数strictbounds 足以限制在定义的locationradius 内返回的位置。
  • 您包含的radius的值太小(10)可能导致ZERO_RESULTS

你可以试试这个请求:

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=london&location=40.64131109999999,-73.77813909999998&radius=10000&components=country:US&strictbounds&key=YOUR_API_KEY

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-10
    • 2014-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多