Method: places.searchNearby

搜尋附近地點。

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 (LocationRestriction)
  },
  "rankPreference": enum (RankPreference)
}
欄位
languageCode

string

系統會顯示地點詳細資料 (如果有的話)。如未指定或無法識別語言代碼,系統可能會傳回任何語言的地點詳細資料,如有這類詳細資料,請優先使用英文。

目前支援的語言清單:https://developers.google.com/maps/faq#languagesupport

regionCode

string

要求來源地區的萬國碼 (Unicode) 國家/地區代碼 (CLDR)。系統會使用這個參數顯示地點詳細資料,例如區域專屬地點名稱 (如有)。這個參數可根據適用法律影響結果。

詳情請參閱 https://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html

請注意,系統目前不支援 3 位數的區碼。

includedTypes[]

string

包含來自 https://developers.google.com/maps/documentation/places/web-service/place-types 的地點類型 (例如「餐廳」或「gas_station」)。

最多可以指定表 A 中的 50 種類型。

如果出現衝突的類型 (例如型別同時出現在 includeTypes 和 excludedTypes 中),系統會傳回 INVALID_COUNTRY 錯誤。

如果「地點類型」指定的類型設有多個類型限制,系統只會傳回符合所有限制的地點。舉例來說,如果有 {includedTypes = ["restaurant"],excludedPrimaryTypes = ["restaurant"]},傳回的地點會提供「餐廳」相關服務,但主要並非「餐廳」。

excludedTypes[]

string

https://developers.google.com/maps/documentation/places/web-service/place-types 中排除的地點類型 (例如「餐廳」或「gas_station」)。

最多可以指定表 A 中的 50 種類型。

如果用戶端同時提供餐廳 (例如餐廳) 和排除類型 (例如咖啡廳),則回應應包括餐廳 (而非咖啡廳) 的地點。回應會包含至少符合其中一個 includeTypes,且不含 excludedTypes 的地點。

如果出現衝突的類型 (例如型別同時出現在 includeTypes 和 excludedTypes 中),系統會傳回 INVALID_COUNTRY 錯誤。

如果「地點類型」指定的類型設有多個類型限制,系統只會傳回符合所有限制的地點。舉例來說,如果有 {includedTypes = ["restaurant"],excludedPrimaryTypes = ["restaurant"]},傳回的地點會提供「餐廳」相關服務,但主要並非「餐廳」。

includedPrimaryTypes[]

string

加入來自 https://developers.google.com/maps/documentation/places/web-service/place-types 的主要地點類型 (例如「餐廳」或「gas_station」)。地點在相關聯的支援類型資料表中只能有單一主要類型。

最多可以指定表 A 中的 50 種類型。

如果主要類型發生衝突 (例如某個類型同時出現在 includePrimaryTypes 和 excludedPrimaryTypes 中),就會傳回 INVALID_COUNTRY 錯誤。

如果「地點類型」指定的類型設有多個類型限制,系統只會傳回符合所有限制的地點。舉例來說,如果有 {includedTypes = ["restaurant"],excludedPrimaryTypes = ["restaurant"]},傳回的地點會提供「餐廳」相關服務,但主要並非「餐廳」。

excludedPrimaryTypes[]

string

已排除 https://developers.google.com/maps/documentation/places/web-service/place-types 的主要地點類型 (例如「餐廳」或「gas_station」)。

最多可以指定表 A 中的 50 種類型。

如果主要類型發生衝突 (例如某個類型同時出現在 includePrimaryTypes 和 excludedPrimaryTypes 中),就會傳回 INVALID_COUNTRY 錯誤。

如果「地點類型」指定的類型設有多個類型限制,系統只會傳回符合所有限制的地點。舉例來說,如果有 {includedTypes = ["restaurant"],excludedPrimaryTypes = ["restaurant"]},傳回的地點會提供「餐廳」相關服務,但主要並非「餐廳」。

maxResultCount

integer

要傳回的結果數上限。這個值必須介於 1 到 20 (預設) 之間 (含首尾)。如果不設定號碼,系統會將其改回上限。如果數字設為負數或超過上限,系統就會傳回 INVALID_COUNTRY 錯誤。

locationRestriction

object (LocationRestriction)

必要欄位。要搜尋的區域。

rankPreference

enum (RankPreference)

回應中的結果排名方式。

回應主體

搜尋附近搜尋的回應原型。

如果成功,回應主體即會包含具有以下結構的資料:

JSON 表示法
{
  "places": [
    {
      object (Place)
    }
  ]
}
欄位
places[]

object (Place)

符合使用者條件的地點清單,例如地點類型、地點數量和特定地點限制。

LocationRestriction

要搜尋的區域。

JSON 表示法
{

  // Union field type can be only one of the following:
  "circle": {
    object (Circle)
  }
  // End of list of possible types for union field type.
}
欄位

聯集欄位 type

type 只能採用下列其中一種設定:

circle

object (Circle)

以中心點和半徑定義的圓形。

RankPreference

回應中的結果排名方式。

列舉
RANK_PREFERENCE_UNSPECIFIED 尚未設定 RankPreference 值。根據預設,將使用 POPULARITY 排名。
DISTANCE 依距離排名結果。
POPULARITY 依熱門程度排名結果。