Google place rank by distance

2020-04-17 04:32发布

What's wrong with this request? I cannot come up with this issue.

https://maps.googleapis.com/maps/api/place/nearbysearch/json?rankby=distance&location=49.4456945,10.1120762&language=IT&sensor=true&key=my-api-key

If I delete the rankby parameter and add radius, it works.

PS: instead of my-api-key there is a valid api key, declared in the console.

5条回答
一夜七次
2楼-- · 2020-04-17 05:18

As the documentation states under 'Optional parameters > rankby > distance', "One or more of keyword, name, or types is required." Add one or more of those parameters to your request and the server will send an OK response.

查看更多
3楼-- · 2020-04-17 05:24

As pushbit say,

If rankby=distance is specified, then one or more of keyword, name, or types is required.

If you want to retieve each place use "type=establishment"

https://maps.googleapis.com/maps/api/place/nearbysearch/json?types=establishment&rankby=distance&location=49.4456945,10.1120762&language=IT&sensor=true&key=your-key

查看更多
Viruses.
4楼-- · 2020-04-17 05:24

rankby — Specifies the order in which results are listed. Note that rankby must not be included if radius (described under Required parameters above) is specified.

Reference-Place Search API Doc

查看更多
你好瞎i
5楼-- · 2020-04-17 05:30

If you use rankby=distance, you need to add at least name or types. I suggest to add types=point_of_interest.

Ps: types=establishment is deprecated, see: Place Types for more details.

查看更多
萌系小妹纸
6楼-- · 2020-04-17 05:35

&key=my-api-key

You need to add API_KEY from Google API console

查看更多
登录 后发表回答