自动完成 return 个半径内的结果
autocomplete to return results within a radius
在我的 google 地图自动完成服务器端查询中,我试图 return 在纬度和经度附近或附近获得结果,到目前为止我已经尝试过了
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
是肯尼迪国际机场的经纬度。
但是当搜索字符串是london时,结果仍然显示。知道如何将结果限制在某个半径/边界或国家/地区内吗?谢谢
以下是我对您的 URL 请求的调查结果:
- 您包含了
strictBounds=true
,这是不正确的,因为参数区分大小写,因此它将在请求中被省略。它应该是 strictbounds
而不是。
- 你也不需要
=true
因为添加参数 strictbounds
足以限制在定义的 location
和 radius
.[=27 中返回的位置=]
- 您包含的
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
在我的 google 地图自动完成服务器端查询中,我试图 return 在纬度和经度附近或附近获得结果,到目前为止我已经尝试过了
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
是肯尼迪国际机场的经纬度。
但是当搜索字符串是london时,结果仍然显示。知道如何将结果限制在某个半径/边界或国家/地区内吗?谢谢
以下是我对您的 URL 请求的调查结果:
- 您包含了
strictBounds=true
,这是不正确的,因为参数区分大小写,因此它将在请求中被省略。它应该是strictbounds
而不是。 - 你也不需要
=true
因为添加参数strictbounds
足以限制在定义的location
和radius
.[=27 中返回的位置=] - 您包含的
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