我发现附近的搜索返回不一致的结果。
有一天我运行了这个查询(转到客户端库)。它返回了我 4 个结果。给定的
keyword=Resorts+World+Sentosa+Equarius+8+Sentosa+Gateway&location=1.2564%2C103.8189&rankby=distance&type=lodging
https://gist.github.com/haibin/20e01d38c10d4da9275439c549a2db91
我改天运行了这个查询(去客户端库)。它返回了我 5 个结果。给定的
keyword=Resorts+World+Sentosa+Equarius+8+Sentosa+Gateway&language=en&location=1.2564%2C103.8189&rankby=distance&type=lodging
https://gist.github.com/haibin/b40e4952b7fddace78d6c37a19542a40
我今天运行了这个查询( curl )。它返回了我 1 个结果。给定的
keyword=Resorts%20World%20Sentosa%20Equarius%208%20Sentosa%20Gateway&language=en&location=1.2564%2C103.8189&rankby=distance&type=lodging
https://gist.github.com/haibin/a65a6d03ace05898913e306840307bdb
知道为什么吗?
最佳答案
可能在使用 rankby=distance
时 google 位置 API 中存在错误参数它跳过某些结果或在“有限半径”中搜索
当我用这些参数运行 curl 时
https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=MY_KEY&keyword=Resorts+World+Sentosa+Equarius+8+Sentosa+Gateway&location=1.2564%2C103.8189&rankby=distance&type=lodging
正如你所说,它只返回一个结果。
但是当我使用半径参数运行时,它会返回更多已接受的结果
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=1.2564,103.8189&type=lodging&keyword=Resorts+World+Sentosa+Equarius+8+Sentosa+Gateway&key=MY_KEY&radius=300
你通过 go lib 获得了更多的结果,因为他们可能在那个或类似的地方修复了它
有关更多信息,您可以查看以下问题:
Google Places API nearby search rankby distance skipping some nearest places
http://www.itgo.me/a/3468386017980994007/google-places-api-nearby-search-rankby-distance-skipping-some-nearest-places
希望这会帮助你。
关于google-places-api - Google 将 API 放在附近搜索不一致的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41651166/