搜索地理位置附近的地点。
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[] |
https://developers.google.com/maps/documentation/places/web-service/place-types 中包含的地点类型(例如“restaurant”或“gas_station”)。 您最多可以指定表 A 中的 50 种类型。 如果存在任何冲突的类型(即,某类型同时出现在 includeTypes 和 excludedTypes 中),则会返回 INVALID_STRING 错误。 如果使用多种类型限制指定了地点类型,则系统仅返回满足所有限制的地点。例如,如果我们有 {includedTypes = ["restaurant"], excludedPrimaryTypes = ["restaurant"]},返回的地点提供与“restaurant”相关的服务,但主要经营范围并非“餐厅”。 |
excludedTypes[] |
https://developers.google.com/maps/documentation/places/web-service/place-types 中排除的地点类型(例如“restaurant”或“gas_station”)。 您最多可以指定表 A 中的 50 种类型。 如果客户端同时提供了 includeType(例如餐馆)和 excludedType(例如咖啡厅),则响应应该包含餐馆而非咖啡馆的地点。响应包含与包含的至少 1 个类型匹配,但与任何 个 excludedType 都不匹配的地点。 如果存在任何冲突的类型(即,某类型同时出现在 includeTypes 和 excludedTypes 中),则会返回 INVALID_STRING 错误。 如果使用多种类型限制指定了地点类型,则系统仅返回满足所有限制的地点。例如,如果我们有 {includedTypes = ["restaurant"], excludedPrimaryTypes = ["restaurant"]},返回的地点提供与“restaurant”相关的服务,但主要经营范围并非“餐厅”。 |
includedPrimaryTypes[] |
https://developers.google.com/maps/documentation/places/web-service/place-types 中包含的主要地点类型(例如“restaurant”或“gas_station”)。一个地点只能有一个与其关联的受支持类型表中的一个主要类型。 您最多可以指定表 A 中的 50 种类型。 如果存在任何存在冲突的主要类型(即,某个类型同时出现在 includePrimaryTypes 和 excludedPrimaryTypes 中),系统将返回 INVALID_STRING 错误。 如果使用多种类型限制指定了地点类型,则系统仅返回满足所有限制的地点。例如,如果我们有 {includedTypes = ["restaurant"], excludedPrimaryTypes = ["restaurant"]},返回的地点提供与“restaurant”相关的服务,但主要经营范围并非“餐厅”。 |
excludedPrimaryTypes[] |
从 https://developers.google.com/maps/documentation/places/web-service/place-types 中排除了主要地点类型(例如“restaurant”或“gas_station”)。 您最多可以指定表 A 中的 50 种类型。 如果存在任何存在冲突的主要类型(即,某个类型同时出现在 includePrimaryTypes 和 excludedPrimaryTypes 中),系统将返回 INVALID_STRING 错误。 如果使用多种类型限制指定了地点类型,则系统仅返回满足所有限制的地点。例如,如果我们有 {includedTypes = ["restaurant"], excludedPrimaryTypes = ["restaurant"]},返回的地点提供与“restaurant”相关的服务,但主要经营范围并非“餐厅”。 |
maxResultCount |
要返回的结果数上限。该值必须介于 1 和 20(含)之间。如果未设置上限,则会回退到上限。如果数值设置为负数或超过上限,则会返回 INVALID_STRING 错误。 |
locationRestriction |
必需。要搜索的区域。 |
rankPreference |
结果在响应中如何排名。 |
响应正文
Search Nearby 的响应原型。
如果成功,响应正文将包含结构如下的数据:
JSON 表示法 |
---|
{
"places": [
{
object ( |
字段 | |
---|---|
places[] |
符合用户要求的地点列表,例如地点类型、地点数量和具体位置限制。 |
LocationRestriction
要搜索的区域。
JSON 表示法 |
---|
{ // Union field |
字段 | |
---|---|
联合字段
|
|
circle |
由中心点和半径定义的圆形。 |
RankPreference
结果在响应中如何排名。
枚举 | |
---|---|
RANK_PREFERENCE_UNSPECIFIED |
未设置 RankPreference 值。将默认使用按 POPULARITY 的排名。 |
DISTANCE |
按距离对结果排名。 |
POPULARITY |
按热门程度对搜索结果排名。 |