5

我有一个应用程序,它使用 places API 来帮助查找目的地(如伦敦)附近的地点。我更喜欢在附近使用,因为它可以让我专注于一个区域,而且与文本搜索相比也更便宜。

不幸的是,我得到的答案没有多大意义。例如,如果我搜索:

name=London Eye

我得到零结果(有或没有引号)。

但如果我按关键字搜索:

keyword=ferris wheel

伦敦眼回归。以下是相关查询:

这有什么押韵或理由吗?

4

2 回答 2

10

好吧,问题是您使用了错误的参数。

检查文档,你会看到你应该使用的参数是keyword而不是name

届时将是:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API_KEY]&sensor=false&location=51.52864165,-0.10179430&radius=47022&keyword=%22london%20eye%22

这对我有用!

编辑:

正如我所说,如果你尝试:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API_KEY]&sensor=false&location=51.52864165,-0.10179430&radius=47022&keyword=%22london%20eye%22&name=%22london%20eye%22

与单独使用这些参数相比,您会得到很多结果。

更新

自 2018 年起,该name参数已被弃用,取而代之的是该keyword参数,因此从现在开始,建议keyword您在请求中仅使用参数。

该文档当前读取

名称- 与 Google 已为此地点编制索引的所有内容匹配的术语。相当于关键字。名称字段不再局限于地名。此字段中的值与关键字字段中的值组合并作为同一搜索字符串的一部分传递。我们建议对所有搜索词仅使用关键字参数。

来源:https ://developers.google.com/places/web-service/search#PlaceSearchRequests

于 2013-08-27T21:08:11.387 回答
0
Users can only use these **types** for response in google API: - https://developers.google.com/maps/documentation/places/web-service/supported_types

If You find a nearby restaurant then this URL use: - https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=30.67995,76.72211&radius=15000&type=restaurant&keyword=cruise&key=AIzaSyAEQyZ-SCeUqGRz40c-nb9lKw

Please use your key for a response. 

Postman Response with Image
https://i.stack.imgur.com/UuAhA.png
于 2022-02-14T10:43:21.810 回答