gpt4 book ai didi

google-places-api - 如何使用文本搜索通过 google place api 按距离对结果进行排序

转载 作者:行者123 更新时间:2023-12-03 04:53:55 26 4
gpt4 key购买 nike

我想按距离排序我所在位置附近的所有餐厅。我正在使用文本搜索与谷歌地方 api 使用此网址:https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurants&location=32.16107,34.806618&radius=200&sensor=true&key=api_key 。我得到的结果很稀疏,没有任何顺序。我尝试了rankby=distance,但根据文档(https://developers.google.com/places/documentation/),你只能在常规搜索中使用它,这意味着使用文本搜索时没有这样的参数选项(我尝试过无论如何->不工作)。我使用文本搜索是因为常规搜索仅返回“类型”:[“机构”]。如何按距离订购 google place api 的文本搜索?我不敢相信谷歌没有创造出一种方法来做到这一点......

最佳答案

您是对的,Places API Textsearch 不支持 rankBy=distance 参数。如果您认为这将是一个有用的功能,请提交 Places API Feature Request .

但是,您可以通过使用 rankBy=distance 参数和 keyword=restaurant 参数执行 Places API 搜索请求来获取所需的结果:

https://maps.googleapis.com/maps/api/place/search/json?keyword=restaurant&location=32.16107,34.806618&rankBy=distance&sensor=false&key=YOUR_API_KEY

keyword 参数与所有可用字段相匹配,包括但不限于名称、类型和地址,以及客户评论和其他第三方内容。

关于google-places-api - 如何使用文本搜索通过 google place api 按距离对结果进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11703597/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com