搜索位置附近的地点。
HTTP 请求
POST https://places.googleapis.com/v1/places:searchNearby
网址采用 gRPC 转码语法。
请求正文
请求正文中包含结构如下的数据:
| JSON 表示法 |
|---|
{ "languageCode": string, "regionCode": string, "includedTypes": [ string ], "excludedTypes": [ string ], "includedPrimaryTypes": [ string ], "excludedPrimaryTypes": [ string ], "maxResultCount": integer, "locationRestriction": { object ( |
| 字段 | |
|---|---|
languageCode |
如果地点详细信息有首选语言版本,系统会显示该版本。如果未指定或无法识别语言代码,系统可能会返回任何语言版本的地点详细信息,但会优先返回英文版本(如果存在)。 目前支持的语言列表:https://developers.google.com/maps/faq#languagesupport。 |
regionCode |
发出请求的位置的 Unicode 国家/地区代码 (CLDR)。此参数用于显示地点详细信息,例如特定于地区的地点名称(如果有)。此参数可能会根据适用法律影响结果。 如需了解详情,请参阅 https://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html。 请注意,目前不支持 3 位数的地区代码。 |
includedTypes[] |
包含的地点类型(例如“restaurant”或“gas_station”),网址为 https://developers.google.com/maps/documentation/places/web-service/place-types。 最多可以指定 表 A 中的 50 种类型。 如果有任何冲突的类型(即某个类型同时出现在 includedTypes 和 excludedTypes 中),系统会返回 INVALID_ARGUMENT 错误。 如果指定了具有多个类型限制的地点类型,则系统只会返回满足所有限制的地点。例如,如果我们有 {includedTypes = ["restaurant"], excludedPrimaryTypes = ["restaurant"]},则返回的地点会提供“restaurant”相关服务,但主要不是作为“restaurants”运营。 |
excludedTypes[] |
排除的地点类型(例如“restaurant”或“gas_station”),网址为 https://developers.google.com/maps/documentation/places/web-service/place-types。 最多可以指定 表 A 中的 50 种类型。 如果客户端同时提供 includedTypes(例如“restaurant”)和 excludedTypes(例如“cafe”),则响应应包含“restaurant”但不是“cafe”的地点。响应包含至少与一个 includedTypes 匹配且与任何 excludedTypes 都不匹配的地点。 如果有任何冲突的类型(即某个类型同时出现在 includedTypes 和 excludedTypes 中),系统会返回 INVALID_ARGUMENT 错误。 如果指定了具有多个类型限制的地点类型,则系统只会返回满足所有限制的地点。例如,如果我们有 {includedTypes = ["restaurant"], excludedPrimaryTypes = ["restaurant"]},则返回的地点会提供“restaurant”相关服务,但主要不是作为“restaurants”运营。 |
includedPrimaryTypes[] |
包含的主要地点类型(例如“restaurant”或“gas_station”),网址为 https://developers.google.com/maps/documentation/places/web-service/place-types。一个地点只能有一个主要类型,且该类型必须来自支持的类型表。 最多可以指定 表 A 中的 50 种类型。 如果有任何冲突的主要类型(即某个类型同时出现在 includedPrimaryTypes 和 excludedPrimaryTypes 中),系统会返回 INVALID_ARGUMENT 错误。 如果指定了具有多个类型限制的地点类型,则系统只会返回满足所有限制的地点。例如,如果我们有 {includedTypes = ["restaurant"], excludedPrimaryTypes = ["restaurant"]},则返回的地点会提供“restaurant”相关服务,但主要不是作为“restaurants”运营。 |
excludedPrimaryTypes[] |
排除的主要地点类型(例如“restaurant”或“gas_station”),网址为 https://developers.google.com/maps/documentation/places/web-service/place-types。 最多可以指定 表 A 中的 50 种类型。 如果有任何冲突的主要类型(即某个类型同时出现在 includedPrimaryTypes 和 excludedPrimaryTypes 中),系统会返回 INVALID_ARGUMENT 错误。 如果指定了具有多个类型限制的地点类型,则系统只会返回满足所有限制的地点。例如,如果我们有 {includedTypes = ["restaurant"], excludedPrimaryTypes = ["restaurant"]},则返回的地点会提供“restaurant”相关服务,但主要不是作为“restaurants”运营。 |
maxResultCount |
页面中结果的数量上限。该值必须介于 1 到 20(默认值)之间,且包含这两个值。如果未设置该值,系统会回退到上限。如果该值设置为负数或超出上限,系统会返回 INVALID_ARGUMENT 错误。 |
locationRestriction |
必需。要搜索的区域。 |
rankPreference |
结果在响应中的排名方式。 |
routingParameters |
可选。影响搜索结果的路由的参数。 |
includeFutureOpeningBusinesses |
可选。如果为 true,则包含尚未开业但将来会开业的商家。 |
响应正文
“附近搜索”的响应 proto。
如果成功,响应正文将包含结构如下的数据:
| JSON 表示法 |
|---|
{ "places": [ { object ( |
| 字段 | |
|---|---|
places[] |
满足用户要求的地点列表,例如地点类型、地点数量和特定位置限制。 |
routingSummaries[] |
路由摘要列表,其中每个条目都与 |
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/maps-platform.places.nearbysearchhttps://www.googleapis.com/auth/maps-platform.placeshttps://www.googleapis.com/auth/cloud-platform
LocationRestriction
要搜索的区域。
| JSON 表示法 |
|---|
{ // Union field |
| 字段 | |
|---|---|
联合字段
|
|
circle |
由中心点和半径定义的圆。 |
RankPreference
结果在响应中的排名方式。
| 枚举 | |
|---|---|
RANK_PREFERENCE_UNSPECIFIED |
未设置 RankPreference 值。默认情况下,系统会按热门程度进行排名。 |
DISTANCE |
按距离对结果进行排名。 |
POPULARITY |
按热门程度对结果进行排名。 |