Google 从 REST 消费的地方未按所需类型过滤

Google Places consuming from REST not filtering by desired type

我正在使用来自 Google 个地点的 REST API 的结果,到目前为止,这就是 Google 地图告诉我关于我周围最近的地方的信息

现在,我正在使用这个 URL 来查询我的结果

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=lat,long&radius=50&type=restaurantkeyword=restaurant&key=MY_API_KEY

根据 this,我正在使用正确的 type = 来过滤我的查询。

我正在按收音机距离为 50 米的餐厅类型进行筛选;现在,其余部分提供给我的结果是:

您可以看到此处显示的结果不是餐厅类型,而是搜索所有 establishments,如常见问题解答所述

Why are some places not returned when I filter by type? It's possible that the place you are looking for has not yet been categorized. All places are categorized as the generic type "establishment" until Google has enough data about a place to categorize it as one of the supported place types.

As a workaround you can pass the place type to the keyword parameter. The keyword parameter is matched to: name, type, address, and customer reviews.

If you would like to add the category type to a place listing yourself, submit a place edit. Once the edit has been approved and published it will appear using the correct type filtering.

但问题是确实在 Google 地图中它似乎是我附近的餐馆,但查询只是 return 我周围的所有场所。

有没有办法修复该响应,以便 return 我附近的餐馆而不是所有地方?

您的 url 查询有错误。您需要在餐厅和关键字之间插入一个“&”。我使用以下查询进行了测试,它看起来是正确的:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-31.41668,-64.1909&radius=50&type=restaurant&keyword=restaurant&key=MY_API_KEY