- HTTP 要求
- 要求主體
- 回應主體
- 授權範圍
- RankPreference
- LocationBias
- LocationRestriction
- EVOptions
- SearchAlongRouteParameters
- Polyline
- ContextualContent
- 理由
- ReviewJustification
- HighlightedText
- HighlightedTextRange
- BusinessAvailabilityAttributesJustification
根據文字查詢搜尋地點。
HTTP 要求
POST https://places.googleapis.com/v1/places:searchText
這個網址使用 gRPC 轉碼語法。
要求主體
要求主體會包含結構如下的資料:
| JSON 表示法 |
|---|
{ "textQuery": string, "languageCode": string, "regionCode": string, "rankPreference": enum ( |
| 欄位 | |
|---|---|
textQuery |
必填。Text Search 的文字查詢。 |
languageCode |
系統會盡可能以偏好語言顯示地點詳細資料。如果未指定或無法辨識語言代碼,系統可能會傳回任何語言的地點詳細資料,並優先傳回英文 (如有)。 目前支援的語言清單:https://developers.google.com/maps/faq#languagesupport。 |
regionCode |
要求來源位置的 Unicode 國家/地區代碼 (CLDR)。這個參數用於顯示 Place Details,例如特定區域的地點名稱 (如有)。這項參數可能會根據適用法律影響結果。 詳情請參閱 https://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html。 請注意,目前不支援 3 位數的區域代碼。 |
rankPreference |
回應中結果的排序方式。 |
includedType |
要求的地點類型。如需支援類型的完整清單,請前往 https://developers.google.com/maps/documentation/places/web-service/place-types。僅支援一個納入類型。 |
openNow |
用於將搜尋範圍限制在目前營業中的地點。預設值為 false。 |
minRating |
篩除平均使用者評分低於此限制的結果。有效值必須是介於 0 至 5 (含) 之間的浮點數,且間隔為 0.5,也就是 [0, 0.5, 1.0, ... , 5.0] (含)。輸入的評分會無條件進位至最接近的 0.5。舉例來說,如果評分為 0.6,系統會排除所有評分低於 1.0 的結果。 |
maxResultCount |
已淘汰:請改用 每頁可傳回的結果數量上限。如果可用的結果數量大於 如果同時指定 |
pageSize |
(選用步驟) 每頁可傳回的結果數量上限。如果可用的結果數量大於 如果同時指定 |
pageToken |
(選用步驟) 屬於接收自前一個 TextSearch 呼叫的網頁權杖。提供此項目即可擷取後續網頁。 進行分頁時,提供給 TextSearch 的所有參數 ( |
priceLevels[] |
用於將搜尋範圍限制在標示為特定價格等級的地點。使用者可以選擇任何價格等級組合。預設會選取所有價格等級。 |
strictTypeFiltering |
用於為 includedType 設定嚴格的類型篩選。如果設為 True,系統只會傳回相同類型的結果。預設為 false。 |
locationBias |
要搜尋的區域。這個位置會做為偏好設定,也就是說,系統可能會傳回指定位置附近的結果。無法與 locationRestriction 一起設定。 |
locationRestriction |
要搜尋的區域。這個位置會做為限制,也就是說,系統不會傳回指定位置以外的結果。無法與 locationBias 一起設定。 |
evOptions |
(選用步驟) 設定地點搜尋要求的可搜尋電動車選項。 |
routingParameters |
(選用步驟) 用於轉送至結果的其他參數。 |
searchAlongRouteParameters |
(選用步驟) 沿路線搜尋的其他參數 proto。 |
includePureServiceAreaBusinesses |
(選用步驟) 如果欄位設為 true,則納入完全無店面區域商家。純無店面區域商家會直接配送或造訪顧客,但不在公司地址為顧客提供服務。例如清潔或水電服務。這類商家在 Google 地圖上沒有實體地址或地點。Places 不會傳回這些商家的 |
includeFutureOpeningBusinesses |
(選用步驟) 如果設為 true,則會納入尚未營業但未來會營業的商家。 |
回應主體
places.searchText 的回應 Proto。
如果成功,回應主體會含有以下結構的資料:
| JSON 表示法 |
|---|
{ "places": [ { object ( |
| 欄位 | |
|---|---|
places[] |
符合使用者文字搜尋條件的地點清單。 |
routingSummaries[] |
路徑摘要清單,其中每個項目都會與 |
contextualContents[] |
實驗功能:詳情請參閱 https://developers.google.com/maps/documentation/places/web-service/experimental/places-generative。 情境內容清單,其中每個項目都會與 places 欄位中相同索引的對應地點建立關聯。系統會優先顯示與要求中 |
nextPageToken |
可做為 |
searchUri |
使用者可以透過連結,在 Google 地圖上使用與要求中指定的相同文字查詢進行搜尋。 |
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/maps-platform.places.textsearchhttps://www.googleapis.com/auth/maps-platform.placeshttps://www.googleapis.com/auth/cloud-platform
RankPreference
回應中結果的排序方式。
| 列舉 | |
|---|---|
RANK_PREFERENCE_UNSPECIFIED |
如果是「紐約市的餐廳」這類類別查詢,預設值為 RELEVANCE。如果是「Mountain View, CA」等非類別查詢,建議不要設定 rankPreference。 |
DISTANCE |
依距離排序結果。 |
RELEVANCE |
依關聯性排序結果。排列順序由一般排名堆疊決定。 |
LocationBias
要搜尋的區域。這個位置會做為偏好設定,也就是說,系統可能會傳回指定位置附近的結果。
| JSON 表示法 |
|---|
{ // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "rectangle": { object ( |
| 欄位 | |
|---|---|
| 以下是互斥欄位清單。回應中最多會設定下列其中一個欄位: | |
rectangle |
由東北角和西南角定義的矩形框。 |
circle |
由中心點和半徑定義的圓形。 |
| 互斥欄位結束。 | |
LocationRestriction
要搜尋的區域。這個位置會做為限制,也就是說,系統不會傳回指定位置以外的結果。
| JSON 表示法 |
|---|
{
// The following is a list of mutually exclusive fields. At most one of the
// fields will be set in a response:
"rectangle": {
object ( |
| 欄位 | |
|---|---|
| 以下是互斥欄位清單。回應中最多會設定下列其中一個欄位: | |
rectangle |
由東北角和西南角定義的矩形框。 |
| 互斥欄位結束。 | |
EVOptions
地點搜尋要求中可搜尋的電動車選項。
| JSON 表示法 |
|---|
{
"minimumChargingRateKw": number,
"connectorTypes": [
enum ( |
| 欄位 | |
|---|---|
minimumChargingRateKw |
(選用步驟) 最低充電速率 (單位為千瓦)。系統會篩除充電速率低於指定速率的地點。 |
connectorTypes[] |
(選用步驟) 偏好的電動車充電插頭類型清單。不支援任何所列接頭類型的地點會遭到篩除。 |
SearchAlongRouteParameters
指定 Routes API 預先計算的折線,定義要搜尋的路徑。沿路線搜尋與使用 locationBias 或 locationRestriction 要求選項來偏重搜尋結果類似。不過,locationBias 和 locationRestriction 選項可讓您指定區域來偏重搜尋結果,而這個選項則可讓您偏重沿著行程路線的結果。
系統不保證結果會沿著提供的路線,而是根據從起點到目的地的最短繞道時間,在折線定義的搜尋區域內排名,並可選擇由 locationBias 或 locationRestriction 定義。結果可能會沿著替代路線顯示,尤其是提供的折線未定義從起點到目的地的最佳路線時。
| JSON 表示法 |
|---|
{
"polyline": {
object ( |
| 欄位 | |
|---|---|
polyline |
必填。路線折線。 |
折線
路線折線。僅支援編碼折線,可做為字串傳遞,並包含壓縮功能,可盡量減少失真。這是 Routes API 的預設輸出內容。
| JSON 表示法 |
|---|
{ // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "encodedPolyline": string // End of mutually exclusive fields. } |
| 欄位 | |
|---|---|
封裝折線類型。Routes API 輸出內容預設為 encoded_polyline。以下是互斥欄位清單。回應中最多會設定下列其中一個欄位: |
|
encodedPolyline |
編碼折線:Routes API 預設傳回的格式。請參閱編碼器和解碼器工具。 |
| 互斥欄位結束。 | |
ContextualContent
與地點查詢相關的內容。
| JSON 表示法 |
|---|
{ "reviews": [ { object ( |
| 欄位 | |
|---|---|
reviews[] |
與地點查詢相關的地點評論清單。 |
photos[] |
這個地點的相片資訊 (包括參考資料),與地點查詢相關。 |
justifications[] |
地點的理由。 |
原因
地點的理由。理由可回答使用者為何對某個地點感興趣。
| JSON 表示法 |
|---|
{ // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "reviewJustification": { object ( |
| 欄位 | |
|---|---|
| 以下是互斥欄位清單。回應中最多會設定下列其中一個欄位: | |
reviewJustification |
|
businessAvailabilityAttributesJustification |
|
| 互斥欄位結束。 | |
ReviewJustification
使用者評論理由。這會醒目顯示使用者評論中,使用者可能感興趣的部分。舉例來說,如果搜尋查詢是「柴燒披薩」,評論理由就會醒目顯示與搜尋查詢相關的文字。
| JSON 表示法 |
|---|
{ "highlightedText": { object ( |
| 欄位 | |
|---|---|
highlightedText |
|
review |
生成醒目顯示文字的評論。 |
HighlightedText
理由中醒目顯示的文字。這是評論本身的一部分。要醒目顯示的確切字詞會由 HighlightedTextRange 標示。文字中可能有多個字詞會醒目顯示。
| JSON 表示法 |
|---|
{
"text": string,
"highlightedTextRanges": [
{
object ( |
| 欄位 | |
|---|---|
text |
|
highlightedTextRanges[] |
醒目顯示文字的範圍清單。 |
HighlightedTextRange
醒目顯示文字的範圍。
| JSON 表示法 |
|---|
{ "startIndex": integer, "endIndex": integer } |
| 欄位 | |
|---|---|
startIndex |
|
endIndex |
|
BusinessAvailabilityAttributesJustification
BusinessAvailabilityAttributes 理由。這會顯示商家可能吸引使用者的部分屬性。
| JSON 表示法 |
|---|
{ "takeout": boolean, "delivery": boolean, "dineIn": boolean } |
| 欄位 | |
|---|---|
takeout |
地點是否提供外帶服務。 |
delivery |
地點是否提供外送服務。 |
dineIn |
地點是否提供內用服務。 |