【问题标题】:difference between a nearby search and a text search in Google Places APIGoogle Places API 中的附近搜索和文本搜索之间的区别
【发布时间】:2023-03-08 05:47:02
【问题描述】:

Google Places API 中的附近搜索文本搜索有什么区别?

例如,使用https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&在半径 1 公里内搜索附近的咖啡馆仅返回 1 个结果 sensor=true&types=cafe&key=your_api_key

使用https://maps.googleapis.com/maps/api/place/textsearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&文本搜索半径1公里内的咖啡馆返回20个结果 query=cafe&key=your_api_key

附近搜索中将types更改为type还会返回20个结果,这些结果也与使用上面的文本搜索找到的结果不同。即https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&type=cafe&key=your_api_key

当您使用上面给出的位置在 google maps android app 上搜索 cafe 时,您得到的结果与使用上面的文本搜索得到的结果相同。

为方便起见,上面的clickable links在下面。

https://maps.googleapis.com/maps/api/place/textsearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&query=cafe&key=

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&type=cafe&key=

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&types=cafe&key=

【问题讨论】:

  • Ishan,虽然我感谢您提供可点击链接以提供真实示例,但让每个人都知道您的 API 密钥可能不是最好的主意。
  • hii 此 api 不提供其他信息,如电话、电子邮件等,因此获取此详细信息需要进行哪些更改

标签: search google-places-api


【解决方案1】:

简单地放置附近的地方可以让您进行更模糊的搜索,但只返回特定的结果。 在文本搜索中,如果您搜索“restaurants”,它将搜索带有“restaurants”文本的位置、场所或名称。任何与餐馆相关的内容。 同时在附近搜索中,如果您搜索“restaurants”,它将返回带有或不带有“restaurants”文本的餐厅场所,但仅返回“restaurants”的场所

【讨论】:

  • 请求限制也有很大不同——附近的地方搜索使用(如预期的那样)1 个请求,而文本搜索使用 10 倍的请求。繁琐但预期的文本搜索会查看更多参数。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多