Places Widgets

PlaceAutocompleteElement 類別

class google.maps.places.PlaceAutocompleteElement extends HTMLElement implements PlaceAutocompleteElementOptions
library "places"

PlaceAutocompleteElement 是 HTMLElement 子類別,可為 Places Autocomplete API 提供 UI 元件。

PlaceAutocompleteElement 會在內部自動使用 AutocompleteSessionToken,將使用者自動完成搜尋的查詢和選取階段分組。

PlacePrediction.toPlace 傳回的 Place 進行第一次 Place.fetchFields 呼叫時,系統會自動加入用於擷取 PlacePrediction 的工作階段符記。

如要進一步瞭解工作階段的運作方式,請參閱 https://developers.google.com/maps/documentation/places/web-service/place-session-tokens

          
<gmp-place-autocomplete
  description="string"
  disabled
  future-opening-businesses-included
  included-primary-types="type1 type2 type3..."
  included-region-codes="c1 c2 c3..."
  internal-usage-attribution-ids="space separated strings"
  maxlength="number"
  name="string"
  no-clear-button
  no-input-icon
  origin="lat,lng"
  placeholder="string"
  pure-service-area-businesses-included
  readonly
  requested-language="string"
  requested-region="string"
  unit-system="value-name">
</gmp-place-autocomplete>
const {PlaceAutocompleteElement} = await google.maps.importLibrary("places");
PlaceAutocompleteElement
PlaceAutocompleteElement(options)
description
attr: description
類型: string optional
輸入元素的說明。螢幕閱讀器會在輸入元素成為焦點時偵測到這項說明。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-describedby
HTML 屬性: description="string"
disabled
attr: disabled
輸入類型: boolean optional
輸出類型: boolean
輸入元素是否已停用。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#disabled
HTML 屬性: disabled
futureOpeningBusinessesIncluded
attr: future-opening-businesses-included
類型: boolean optional
是否要納入尚未營業但預計在未來營業的地點。
HTML 屬性: future-opening-businesses-included
includedPrimaryTypes
attr: included-primary-types
類型: Array<string> optional
包含主要地點類型 (例如「restaurant」或「gas_station」)。

只有主要類型包含在此清單中的地點,才會傳回。最多可指定 5 個值。如未指定任何類型,系統會傳回所有地點類型。
HTML 屬性: included-primary-types="type1 type2 type3..."
includedRegionCodes
attr: included-region-codes
類型: Array<string> optional
只納入指定區域的結果,最多可指定 15 個 CLDR 雙字元區域代碼。空集合不會限制結果。如果同時設定 locationRestrictionincludedRegionCodes,結果會位於交集區域。
HTML 屬性: included-region-codes="c1 c2 c3..."
internalUsageAttributionIds
attr: internal-usage-attribution-ids
輸入類型: Iterable<string> optional
輸出類型: Array<string> optional
用來將呼叫歸因於特定套件或 OSS 程式庫的 ID。
HTML 屬性: internal-usage-attribution-ids="space separated strings"
locationBias
類型: LocationBias optional
搜尋地點時使用的軟性邊界或提示。
locationRestriction
類型: LocationRestriction optional
限制搜尋結果的界線。
maxlength
attr: maxlength
類型: number optional
使用者可輸入的字元數上限。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
HTML 屬性: maxlength="number"
name
attr: name
類型: string optional
輸入元素要使用的名稱。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name。與輸入內容的名稱屬性行為相同。請注意,提交表單時會使用這個名稱。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
HTML 屬性: name="string"
noClearButton
attr: no-clear-button
輸入類型: boolean optional
輸出類型: boolean
是否隱藏清除按鈕。
HTML 屬性: no-clear-button
noInputIcon
attr: no-input-icon
輸入類型: boolean optional
輸出類型: boolean
是否要隱藏輸入圖示。
HTML 屬性: no-input-icon
origin
attr: origin
輸入類型: LatLng|LatLngLiteral|LatLngAltitude|LatLngAltitudeLiteral optional
輸出類型: LatLngAltitude optional
計算距離的起點。如未指定,系統就不會計算距離。系統不會使用海拔高度 (如有) 進行計算。
HTML 屬性:
  • origin="lat,lng"
  • origin="lat,lng,altitude"
placeholder
attr: placeholder
類型: string optional
輸入元素的預留位置文字。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
HTML 屬性: placeholder="string"
pureServiceAreaBusinessesIncluded
attr: pure-service-area-businesses-included
類型: boolean optional
是否要納入純區域服務商家。
HTML 屬性: pure-service-area-businesses-included
readonly
attr: readonly
輸入類型: boolean optional
輸出類型: boolean
輸入元素是否為唯讀。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly
HTML 屬性: readonly
requestedLanguage
attr: requested-language
類型: string optional
盡可能提供語言 ID,指出應以哪種語言傳回結果。系統可能會優先顯示所選語言的結果,但建議不限於該語言。請參閱支援語言清單
HTML 屬性: requested-language="string"
requestedRegion
attr: requested-region
類型: string optional
用於格式化和篩選結果的區域代碼。這不會將建議限制在該國家/地區。區碼接受 ccTLD (「頂層網域」) 的兩位字元值。多數 ccTLD 代碼與 ISO 3166-1 代碼相同,只有少數例外。舉例來說,英國的 ccTLD 是「uk」(.co.uk),而 ISO 3166-1 代碼是「gb」(技術上是指「大不列顛及北愛爾蘭聯合王國」實體)。
HTML 屬性: requested-region="string"
unitSystem
attr: unit-system
輸入類型: UnitSystem optional
輸出類型: UnitSystem optional
顯示距離時使用的單位系統。如未指定,系統會根據 requestedRegion 判斷單位系統。
HTML 屬性: unit-system="value-name"
value
輸入類型: string optional
輸出類型: string
輸入元素的值。
clear-icon
將已插入的元素放在清除圖示位置。輸入內容時,輸入框結尾會顯示清除按鈕。
input-icon
將已插入的元素放在輸入圖示位置。輸入圖示會以內嵌模式顯示在輸入框開頭。
prediction-item-icon
這個插槽只接受一個 <template> 元素,做為預測項目旁顯示的圖示。
focus-ring
用於在聚焦元素 (輸入或預測項目) 周圍顯示焦點環的元素
input
自動完成元素的輸入元素。
prediction-item
預測下拉式選單中的項目,代表單一預測。
prediction-item-icon
顯示在預測查詢字串清單中每個項目左側的圖示。
prediction-item-main-text
預測項目的一部分,是預測結果的主要文字。就地理位置而言,這包含地方資訊名稱 (例如「Sydney」) 或街道名稱及門牌號碼 (例如「10 King Street」)。預設情況下,prediction-item-main-text 為黑色。如果預測項目中有任何額外文字,則會位於預測項目主要文字之外,並沿用預測項目的樣式。在預設情況下會以灰色顯示。這組額外文字通常是地址。
prediction-item-match
傳回的預測結果中,與使用者輸入內容相符的部分。根據預設,這組相符文字會以粗體字標示。請注意,相符文字只會在 prediction-item-main-text 中醒目顯示。
prediction-item-nonmatch
預測結果主要文字中與使用者輸入內容不符的部分。
prediction-item-secondary-text
預測項目的一部分,是預測結果的次要文字。這組額外文字通常是地址。
prediction-item-selected
使用者透過鍵盤導覽至的項目。注意:選取的項目會受到這個部分樣式和預測項目部分樣式的影響。
prediction-list
包含「地方資訊自動完成」服務所傳回預測查詢字串清單的視覺元素。這份清單會以下拉式選單的形式,顯示在 PlaceAutocompleteElement 下方。
background-color
覆寫元素的背景顏色。
border
覆寫元素的邊框。
border-radius
覆寫元素的邊框半徑。
color
覆寫元素的字型。
color-scheme
指出這個元素可採用哪種色彩配置。詳情請參閱color-scheme 說明文件。預設值為 color-scheme: light dark
font
覆寫元素的字型。
font-family
覆寫元素的字型。
font-size
覆寫元素的字型。
font-style
覆寫元素的字型。
font-weight
覆寫元素的字型。
line-height
覆寫元素的字型。
已繼承: addEventListenerremoveEventListener
gmp-error
function(errorEvent)
引數:
  • errorEvent: Event optional
當後端要求遭到拒絕時 (例如 API 金鑰不正確),系統會觸發這項事件。這個事件不會冒泡。
gmp-select
function(placePredictionSelectEvent)
引數:
使用者選取地點預測結果時,系統會觸發這項事件。其中包含 PlacePrediction 物件,可轉換為 Place 物件。

PlaceAutocompleteElementOptions interface

介面 google.maps.places.PlaceAutocompleteElementOptions

建構 PlaceAutocompleteElement 的選項。如要瞭解各項屬性,請參閱 PlaceAutocompleteElement 類別中同名的屬性。

description
選填
類型: string optional
輸入元素的說明。當輸入元素成為焦點時,螢幕閱讀器會偵測到這項說明。
disabled
選填
類型: boolean optional
futureOpeningBusinessesIncluded
選填
類型: boolean optional
includedPrimaryTypes
選填
類型: Array<string> optional
includedRegionCodes
選填
類型: Array<string> optional
internalUsageAttributionIds
選填
類型: Iterable<string> optional
locationBias
選填
類型: LocationBias optional
locationRestriction
選填
類型: LocationRestriction optional
maxlength
選填
類型: number optional
name
選填
類型: string optional
noClearButton
選填
類型: boolean optional
noInputIcon
選填
類型: boolean optional
origin
選填
placeholder
選填
類型: string optional
pureServiceAreaBusinessesIncluded
選填
類型: boolean optional
readonly
選填
類型: boolean optional
requestedLanguage
選填
類型: string optional
requestedRegion
選填
類型: string optional
unitSystem
選填
類型: UnitSystem optional
value
選填
類型: string optional
輸入元素的值。

PlacePredictionSelectEvent 類別

class google.maps.places.PlacePredictionSelectEvent extends Event
library "places"

使用者透過 PlaceAutocompleteElement 選取預測項目後,系統就會建立這項事件。使用 event.placePrediction 存取所選項目。

呼叫 PlacePrediction.toPlace,將 placePrediction 轉換為 Place

const {PlacePredictionSelectEvent} = await google.maps.importLibrary("places");
placePrediction
readonly
類型: PlacePrediction
呼叫 PlacePrediction.toPlace,將其轉換為 Place

BasicPlaceAutocompleteElement class

class google.maps.places.BasicPlaceAutocompleteElement extends HTMLElement implements BasicPlaceAutocompleteElementOptions
library "places"

BasicPlaceAutocompleteElement 是 HTMLElement 子類別,可為 Places Autocomplete API 提供 UI 元件。

          
<gmp-basic-place-autocomplete
  description="string"
  disabled
  future-opening-businesses-included
  included-primary-types="type1 type2 type3..."
  included-region-codes="c1 c2 c3..."
  internal-usage-attribution-ids="space separated strings"
  maxlength="number"
  name="string"
  no-clear-button
  no-input-icon
  origin="lat,lng"
  placeholder="string"
  pure-service-area-businesses-included
  readonly
  requested-language="string"
  requested-region="string"
  unit-system="value-name">
</gmp-basic-place-autocomplete>
const {BasicPlaceAutocompleteElement} = await google.maps.importLibrary("places");
BasicPlaceAutocompleteElement
BasicPlaceAutocompleteElement(options)
description
attr: description
類型: string optional
輸入元素的說明。螢幕閱讀器會在輸入元素成為焦點時偵測到這項說明。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-describedby
HTML 屬性: description="string"
disabled
attr: disabled
輸入類型: boolean optional
輸出類型: boolean
輸入元素是否已停用。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#disabled
HTML 屬性: disabled
futureOpeningBusinessesIncluded
attr: future-opening-businesses-included
類型: boolean optional
是否要納入尚未營業但預計在未來營業的地點。
HTML 屬性: future-opening-businesses-included
includedPrimaryTypes
attr: included-primary-types
類型: Array<string> optional
包含主要地點類型 (例如「restaurant」或「gas_station」)。

只有主要類型包含在此清單中的地點,才會傳回。最多可指定 5 個值。如未指定任何類型,系統會傳回所有地點類型。
HTML 屬性: included-primary-types="type1 type2 type3..."
includedRegionCodes
attr: included-region-codes
類型: Array<string> optional
只納入指定區域的結果,最多可指定 15 個 CLDR 雙字元區域代碼。空集合不會限制結果。如果同時設定 locationRestrictionincludedRegionCodes,結果會位於交集區域。
HTML 屬性: included-region-codes="c1 c2 c3..."
internalUsageAttributionIds
attr: internal-usage-attribution-ids
輸入類型: Iterable<string> optional
輸出類型: Array<string> optional
用來將呼叫歸因於特定套件或 OSS 程式庫的 ID。
HTML 屬性: internal-usage-attribution-ids="space separated strings"
locationBias
類型: LocationBias optional
搜尋地點時使用的軟性邊界或提示。
locationRestriction
類型: LocationRestriction optional
限制搜尋結果的界線。
maxlength
attr: maxlength
類型: number optional
使用者可輸入的字元數上限。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
HTML 屬性: maxlength="number"
name
attr: name
類型: string optional
輸入元素要使用的名稱。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name。與輸入內容的名稱屬性行為相同。請注意,提交表單時會使用這個名稱。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
HTML 屬性: name="string"
noClearButton
attr: no-clear-button
輸入類型: boolean optional
輸出類型: boolean
是否隱藏清除按鈕。
HTML 屬性: no-clear-button
noInputIcon
attr: no-input-icon
輸入類型: boolean optional
輸出類型: boolean
是否要隱藏輸入圖示。
HTML 屬性: no-input-icon
origin
attr: origin
輸入類型: LatLng|LatLngLiteral|LatLngAltitude|LatLngAltitudeLiteral optional
輸出類型: LatLngAltitude optional
計算距離的起點。如未指定,系統就不會計算距離。系統不會使用海拔高度 (如有) 進行計算。
HTML 屬性:
  • origin="lat,lng"
  • origin="lat,lng,altitude"
placeholder
attr: placeholder
類型: string optional
輸入元素的預留位置文字。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
HTML 屬性: placeholder="string"
pureServiceAreaBusinessesIncluded
attr: pure-service-area-businesses-included
類型: boolean optional
是否要納入純區域服務商家。
HTML 屬性: pure-service-area-businesses-included
readonly
attr: readonly
輸入類型: boolean optional
輸出類型: boolean
輸入元素是否為唯讀。詳情請參閱 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly
HTML 屬性: readonly
requestedLanguage
attr: requested-language
類型: string optional
盡可能提供語言 ID,指出應以哪種語言傳回結果。系統可能會優先顯示所選語言的結果,但建議不限於該語言。請參閱支援語言清單
HTML 屬性: requested-language="string"
requestedRegion
attr: requested-region
類型: string optional
用於格式化和篩選結果的區域代碼。這不會將建議限制在該國家/地區。區碼接受 ccTLD (「頂層網域」) 的兩位字元值。多數 ccTLD 代碼與 ISO 3166-1 代碼相同,只有少數例外。舉例來說,英國的 ccTLD 是「uk」(.co.uk),而 ISO 3166-1 代碼是「gb」(技術上是指「大不列顛及北愛爾蘭聯合王國」實體)。
HTML 屬性: requested-region="string"
unitSystem
attr: unit-system
輸入類型: UnitSystem optional
輸出類型: UnitSystem optional
顯示距離時使用的單位系統。如未指定,系統會根據 requestedRegion 判斷單位系統。
HTML 屬性: unit-system="value-name"
clear-icon
將已插入的元素放在清除圖示位置。輸入內容時,輸入框結尾會顯示清除按鈕。
input-icon
將已插入的元素放在輸入圖示位置。輸入圖示會以內嵌模式顯示在輸入框開頭。
prediction-item-icon
這個插槽只接受一個 <template> 元素,做為預測項目旁顯示的圖示。
focus-ring
用於在聚焦元素 (輸入或預測項目) 周圍顯示焦點環的元素
input
自動完成元素的輸入元素。
prediction-item
預測下拉式選單中的項目,代表單一預測。
prediction-item-icon
顯示在預測查詢字串清單中每個項目左側的圖示。
prediction-item-main-text
預測項目的一部分,是預測結果的主要文字。就地理位置而言,這包含地方資訊名稱 (例如「Sydney」) 或街道名稱及門牌號碼 (例如「10 King Street」)。預設情況下,prediction-item-main-text 為黑色。如果預測項目中有任何額外文字,則會位於預測項目主要文字之外,並沿用預測項目的樣式。在預設情況下會以灰色顯示。這組額外文字通常是地址。
prediction-item-match
傳回的預測結果中,與使用者輸入內容相符的部分。根據預設,這組相符文字會以粗體字標示。請注意,相符文字只會在 prediction-item-main-text 中醒目顯示。
prediction-item-nonmatch
預測結果主要文字中與使用者輸入內容不符的部分。
prediction-item-secondary-text
預測項目的一部分,是預測結果的次要文字。這組額外文字通常是地址。
prediction-item-selected
使用者透過鍵盤導覽至的項目。注意:選取的項目會受到這個部分樣式和預測項目部分樣式的影響。
prediction-list
包含「地方資訊自動完成」服務所傳回預測查詢字串清單的視覺元素。這份清單會以下拉式選單的形式,顯示在 PlaceAutocompleteElement 下方。
background-color
覆寫元素的背景顏色。
border
覆寫元素的邊框。
border-radius
覆寫元素的邊框半徑。
color
覆寫元素的字型。
color-scheme
指出這個元素可採用哪種色彩配置。詳情請參閱color-scheme 說明文件。預設值為 color-scheme: light dark
font
覆寫元素的字型。
font-family
覆寫元素的字型。
font-size
覆寫元素的字型。
font-style
覆寫元素的字型。
font-weight
覆寫元素的字型。
line-height
覆寫元素的字型。
已繼承: addEventListenerremoveEventListener
gmp-error
function(errorEvent)
引數:
  • errorEvent: Event optional
當後端要求遭到拒絕時 (例如 API 金鑰不正確),系統會觸發這項事件。這個事件不會冒泡。
gmp-select
function(placeSelectEvent)
引數:
使用者選取地點預測時,系統會觸發這項事件。包含 Place 物件。

BasicPlaceAutocompleteElementOptions 介面

介面 google.maps.places.BasicPlaceAutocompleteElementOptions

建構 BasicPlaceAutocompleteElement 的選項。

description
選填
類型: string optional
輸入元素的說明。當輸入元素成為焦點時,螢幕閱讀器會偵測到這項說明。
disabled
選填
類型: boolean optional
futureOpeningBusinessesIncluded
選填
類型: boolean optional
includedPrimaryTypes
選填
類型: Array<string> optional
includedRegionCodes
選填
類型: Array<string> optional
internalUsageAttributionIds
選填
類型: Iterable<string> optional
locationBias
選填
類型: LocationBias optional
locationRestriction
選填
類型: LocationRestriction optional
maxlength
選填
類型: number optional
name
選填
類型: string optional
noClearButton
選填
類型: boolean optional
noInputIcon
選填
類型: boolean optional
origin
選填
placeholder
選填
類型: string optional
pureServiceAreaBusinessesIncluded
選填
類型: boolean optional
readonly
選填
類型: boolean optional
requestedLanguage
選填
類型: string optional
requestedRegion
選填
類型: string optional
unitSystem
選填
類型: UnitSystem optional

PlaceDetailsElement class

class google.maps.places.PlaceDetailsElement extends HTMLElement implements PlaceDetailsElementOptions
library "places"

以完整版面配置顯示地點詳細資料。附加 PlaceDetailsPlaceRequestElementPlaceDetailsLocationRequestElement,指定要顯示的位置。附加 PlaceContentConfigElementPlaceStandardContentElementPlaceAllContentElement,指定要算繪的內容。

示例:

 <gmp-place-details>
  <gmp-place-details-place-request
    place="PLACE_ID"
  ></gmp-place-details-place-request>
  <gmp-place-content-config>
    <gmp-place-media lightbox-preferred></gmp-place-media>
  </gmp-place-content-config>
</gmp-place-details>

如要使用這個元素,請在 Google Cloud 控制台中,為專案啟用 Places UI Kit API

<gmp-place-details
  internal-usage-attribution-ids="space separated strings">
</gmp-place-details>
const {PlaceDetailsElement} = await google.maps.importLibrary("places");
PlaceDetailsElement
PlaceDetailsElement([options])
參數:
internalUsageAttributionIds
attr: internal-usage-attribution-ids
輸入類型: Iterable<string> optional
輸出類型: Array<string> optional
用來將呼叫歸因於特定套件或 OSS 程式庫的 ID。
HTML 屬性: internal-usage-attribution-ids="space separated strings"
place
readonly
類型: Place optional
唯讀。地點物件,內含目前顯示地點的 ID、位置和可視區域。
--gmp-button-border-color
「在 Google 地圖中開啟」按鈕的邊框顏色。
--gmp-button-border-radius
「在地圖中開啟」按鈕的邊框半徑。
--gmp-button-border-width
「在 Google 地圖中開啟」按鈕的框線寬度。
--gmp-collage-border-radius-outer
媒體拼貼外角的圓角半徑。
--gmp-dialog-border-radius
Google 地圖揭露對話方塊的邊框半徑。
--gmp-mat-color-disabled-surface
表面顏色,用於表示停用狀態或不存在。用於空白的評論星號。
--gmp-mat-color-info
具有資訊情緒的 UI 元素顏色。用於輪椅圖示。
--gmp-mat-color-negative
情緒負面 UI 元素的顏色。用於「現在營業中」狀態的「已關閉」文字。
--gmp-mat-color-neutral-container
中性填滿 UI 元素的容器顏色。用於圖片預留位置和顯示發布日期徽章。
--gmp-mat-color-on-neutral-container
文字和圖示的顏色,與中性容器顏色形成對比。用於評論發布日期徽章,以及電動車充電樁供應情形徽章 (如果無法使用)。
--gmp-mat-color-on-positive-container
文字和圖示的顏色,與正向容器顏色形成對比。如果適用,則用於電動車充電樁供應情形徽章。
--gmp-mat-color-on-secondary-container
文字和圖示的顏色,與輔色容器顏色形成對比。用於「在 Google 地圖中開啟」按鈕上的文字和圖示。
--gmp-mat-color-on-surface
文字和圖示的顏色,可搭配任何介面顏色。用於一般文字。
--gmp-mat-color-on-surface-variant
在任何 Surface 顏色上,用於文字和圖示的低強調色。用於較不強調的文字。
--gmp-mat-color-outline-decorative
非互動式元素的輪廓顏色。用於元素的邊框。
--gmp-mat-color-positive
情緒正向的 UI 元素顏色。用於「營業中」狀態的「營業中」文字。
--gmp-mat-color-positive-container
用於傳達正面情緒的 UI 元素容器顏色。有電動車充電樁時,會顯示電動車充電樁供應情形徽章。
--gmp-mat-color-primary
與介面顏色對比的互動式文字和圖示顏色。用於評論數、Google 地圖揭露資訊對話方塊中的連結、網站連結、總覽分頁中的圖示,以及分頁列標題上的 (懸停 / 焦點 / 文字顏色)。
--gmp-mat-color-secondary-container
相較於表面,較不顯眼的填滿顏色,適用於色調按鈕等隱性元件。用於「在 Google 地圖中開啟」按鈕的背景。
--gmp-mat-color-surface
背景顏色。用於元素和 Google 地圖揭露資訊對話方塊的背景。
--gmp-mat-font-body-medium
用於 Google 地圖揭露資訊對話方塊中的地點地址、評分、類型、價格、目前營業狀態、營業時間、評論、電話號碼、網站、加號代碼、熱門功能和內文。
--gmp-mat-font-body-small
用於「關於」分頁中功能清單的內文。
--gmp-mat-font-display-small
用於地點名稱和「關於」分頁中每個功能標題的文字。
--gmp-mat-font-family
用於所有文字的基礎字型系列。
--gmp-mat-font-headline-medium
用於 Google 地圖揭露事項對話方塊中的標題文字。
--gmp-mat-font-label-large
用於分頁標題、「在 Google 地圖中開啟」按鈕、相片庫中的評論者作者資訊文字、評論專區中的評論者作者資訊文字,以及 Google 地圖揭露事項對話方塊中的連結。
--gmp-mat-font-label-medium
用於相片計數徽章和評論發布日期徽章。
--gmp-mat-font-title-small
用於「關於」分頁中各個部分的標題。
--gmp-mat-spacing-extra-large
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-extra-small
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-large
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-medium
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-small
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-two-extra-large
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-star-rating-color
評分中實心星號的顏色。
background-color
覆寫元素的背景顏色。
border
覆寫元素的邊框。
border-radius
覆寫元素的邊框半徑。
color-scheme
指出這個元素可採用哪種色彩配置。詳情請參閱color-scheme 說明文件。預設值為 color-scheme: light dark
font-size
縮放元素中的所有文字和圖示,這些項目在內部是以 em 為單位定義。預設值為 16px
已繼承: addEventListenerremoveEventListener
gmp-error
function(event)
引數:
當後端要求遭到拒絕時 (例如 API 金鑰不正確),系統會觸發這項事件。這個事件不會冒泡。
gmp-load
function(event)
引數:
當元素載入並算繪內容時,系統會觸發這個事件。這個事件不會冒泡。

PlaceDetailsElementOptions interface

介面 google.maps.places.PlaceDetailsElementOptions

PlaceDetailsElement」的選項。

internalUsageAttributionIds
選填
類型: Iterable<string> optional
用來將呼叫歸因於特定套件或 OSS 程式庫的 ID。

PlaceDetailsCompactElement class

class google.maps.places.PlaceDetailsCompactElement extends HTMLElement implements PlaceDetailsCompactElementOptions
library "places"

以精簡版面配置顯示地點詳細資料。附加 PlaceDetailsPlaceRequestElementPlaceDetailsLocationRequestElement,指定要顯示的地點。附加 PlaceContentConfigElementPlaceStandardContentElementPlaceAllContentElement,指定要算繪的內容。

示例:

 <gmp-place-details-compact>
  <gmp-place-details-place-request
    place="PLACE_ID"
  ></gmp-place-details-place-request>
  <gmp-place-content-config>
    <gmp-place-media lightbox-preferred></gmp-place-media>
  </gmp-place-content-config>
</gmp-place-details-compact>

如要使用這個元素,請在 Google Cloud 控制台中,為專案啟用 Places UI Kit API

 
<gmp-place-details-compact
  internal-usage-attribution-ids="space separated strings"
  orientation="value-name"
  truncation-preferred>
</gmp-place-details-compact>
const {PlaceDetailsCompactElement} = await google.maps.importLibrary("places");
PlaceDetailsCompactElement
PlaceDetailsCompactElement([options])
參數:
internalUsageAttributionIds
attr: internal-usage-attribution-ids
輸入類型: Iterable<string> optional
輸出類型: Array<string> optional
用來將呼叫歸因於特定套件或 OSS 程式庫的 ID。
HTML 屬性: internal-usage-attribution-ids="space separated strings"
orientation
attr: orientation
類型: PlaceDetailsOrientation optional
預設值: PlaceDetailsOrientation.VERTICAL
元素的方向變體 (垂直或水平)。
HTML 屬性: orientation="value-name"
place
readonly
類型: Place optional
唯讀。地點物件,內含目前顯示地點的 ID、位置和可視區域。
truncationPreferred
attr: truncation-preferred
輸入類型: boolean optional
輸出類型: boolean
預設值: false
如果為 true,系統會截斷地點名稱和地址,以符合單行顯示空間,而不是換行。
HTML 屬性: truncation-preferred
--gmp-button-border-color
「在 Google 地圖中開啟」按鈕的邊框顏色。
--gmp-button-border-radius
「在地圖中開啟」按鈕的邊框半徑。
--gmp-button-border-width
「在 Google 地圖中開啟」按鈕的框線寬度。
--gmp-dialog-border-radius
Google 地圖揭露對話方塊的邊框半徑。
--gmp-mat-color-info
具有資訊情緒的 UI 元素顏色。用於輪椅圖示。
--gmp-mat-color-negative
情緒負面 UI 元素的顏色。用於「現在營業中」狀態的「已關閉」文字。
--gmp-mat-color-neutral-container
中性填滿 UI 元素的容器顏色。用於圖片預留位置。
--gmp-mat-color-on-secondary-container
文字和圖示的顏色,與次要容器顏色形成對比。用於「在 Google 地圖中開啟」按鈕上的文字和圖示。
--gmp-mat-color-on-surface
文字和圖示的顏色,可搭配任何介面顏色。用於一般文字。
--gmp-mat-color-on-surface-variant
在任何 Surface 顏色上,用於文字和圖示的低強調色。用於較不強調的文字。
--gmp-mat-color-outline-decorative
非互動式元素的輪廓顏色。用於元素的邊框。
--gmp-mat-color-positive
情緒正向的 UI 元素顏色。用於「營業中」狀態的「營業中」文字。
--gmp-mat-color-primary
與介面顏色對比的互動式文字和圖示顏色。用於評論數,以及 Google 地圖揭露資訊對話方塊中的連結。
--gmp-mat-color-secondary-container
相較於表面,較不顯眼的填滿顏色,適用於色調按鈕等隱性元件。用於「在 Google 地圖中開啟」按鈕的背景。
--gmp-mat-color-surface
背景顏色。用於元素和 Google 地圖揭露資訊對話方塊的背景。
--gmp-mat-font-body-medium
用於 Google 地圖揭露事項對話方塊中的內文。
--gmp-mat-font-body-small
用於地點地址、評分、類型、價格和目前營業狀態。
--gmp-mat-font-family
用於所有文字的基礎字型系列。
--gmp-mat-font-headline-medium
用於 Google 地圖揭露事項對話方塊中的標題文字。
--gmp-mat-font-label-large
用於「在 Google 地圖中開啟」按鈕,以及 Google 地圖揭露事項對話方塊中的連結,和相片庫中的評論者作者資訊文字。
--gmp-mat-font-label-medium
用於相片計數徽章。
--gmp-mat-font-title-small
用於地點名稱。
--gmp-mat-spacing-extra-small
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-large
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-medium
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-small
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-star-rating-color
評分中實心星號的顏色。
--gmp-thumbnail-border-radius
地點縮圖的邊框半徑。
background-color
覆寫元素的背景顏色。
border
覆寫元素的邊框。
border-radius
覆寫元素的邊框半徑。
color-scheme
指出這個元素可採用哪種色彩配置。詳情請參閱color-scheme 說明文件。預設值為 color-scheme: light dark
font-size
縮放元素中的所有文字和圖示,這些文字和圖示會在內部以 em 定義。預設值為 16px
已繼承: addEventListenerremoveEventListener
gmp-error
function(event)
引數:
當後端要求遭到拒絕時 (例如 API 金鑰不正確),系統會觸發這項事件。這個事件不會冒泡。
gmp-load
function(event)
引數:
當元素載入並算繪內容時,系統會觸發這個事件。這個事件不會冒泡。

PlaceDetailsCompactElementOptions interface

介面 google.maps.places.PlaceDetailsCompactElementOptions

PlaceDetailsCompactElement」的選項。

internalUsageAttributionIds
選填
類型: Iterable<string> optional
用來將呼叫歸因於特定套件或 OSS 程式庫的 ID。
orientation
選填
類型: PlaceDetailsOrientation optional
truncationPreferred
選填
類型: boolean optional

PlaceDetailsOrientation 常數

常數 google.maps.places.PlaceDetailsOrientation
程式庫 "places"

PlaceDetailsCompactElement」的方向變體。

這些常數也可做為字串使用。在 TypeScript 中,字串常值是由 PlaceDetailsOrientationString 型別定義。

const {PlaceDetailsOrientation} = await google.maps.importLibrary("places");
HORIZONTAL 橫向螢幕方向。
VERTICAL 直向。

PlaceDetailsPlaceRequestElement class

class google.maps.places.PlaceDetailsPlaceRequestElement extends HTMLElement implements PlaceDetailsPlaceRequestElementOptions
library "places"

設定 PlaceDetailsCompactElementPlaceDetailsElement,根據地點物件、ID 或資源名稱載入資料。將這個元素附加為 PlaceDetailsCompactElementPlaceDetailsElement 的子項,即可載入指定地點的資料。例如:

 <gmp-place-details>
  <gmp-place-details-place-request
    place="PLACE_ID"
  ></gmp-place-details-place-request>
</gmp-place-details>

<gmp-place-details-place-request
  place="places/###">
</gmp-place-details-place-request>
const {PlaceDetailsPlaceRequestElement} = await google.maps.importLibrary("places");
PlaceDetailsPlaceRequestElement
PlaceDetailsPlaceRequestElement([options])
參數:
place
attr: place
輸入類型: Place|string optional
輸出類型: Place optional
預設值: null
要在 Place Details Compact 元素中顯示詳細資料的地點物件、ID 或資源名稱。這項屬性會以資源名稱的形式反映至屬性。
HTML 屬性: place="places/###"
已繼承: addEventListenerremoveEventListener

PlaceDetailsPlaceRequestElementOptions interface

介面 google.maps.places.PlaceDetailsPlaceRequestElementOptions

PlaceDetailsPlaceRequestElement」的選項。

place
選填
類型: Place|string optional

PlaceDetailsLocationRequestElement class

class google.maps.places.PlaceDetailsLocationRequestElement extends HTMLElement implements PlaceDetailsLocationRequestElementOptions
library "places"

設定 PlaceDetailsCompactElementPlaceDetailsElement,根據位置載入資料。將這個元素附加為 PlaceDetailsCompactElementPlaceDetailsElement 的子項,即可載入指定位置的資料。例如:

 <gmp-place-details>
  <gmp-place-details-location-request
    location="37.6207665,-122.4284806"
  ></gmp-place-details-location-request>
</gmp-place-details>

<gmp-place-details-location-request
  location="lat,lng">
</gmp-place-details-location-request>
const {PlaceDetailsLocationRequestElement} = await google.maps.importLibrary("places");
PlaceDetailsLocationRequestElement
PlaceDetailsLocationRequestElement([options])
參數:
location
attr: location
輸入類型: LatLng|LatLngLiteral|LatLngAltitude|LatLngAltitudeLiteral optional
輸出類型: LatLngAltitude optional
預設值: null
要在 Place Details 元素中顯示詳細資料的地點。正規化為 LatLngAltitude
HTML 屬性: location="lat,lng"
已繼承: addEventListenerremoveEventListener

PlaceDetailsLocationRequestElementOptions interface

介面 google.maps.places.PlaceDetailsLocationRequestElementOptions

PlaceDetailsLocationRequestElement」的選項。

location
選填
要顯示地點的位置。

PlaceSearchElement class

class google.maps.places.PlaceSearchElement extends HTMLElement implements PlaceSearchElementOptions
library "places"

以清單形式顯示地點搜尋結果。附加 PlaceTextSearchRequestElementPlaceNearbySearchRequestElement,指定要算繪結果的要求。附加 PlaceContentConfigElementPlaceStandardContentElementPlaceAllContentElement,指定要算繪的內容。

示例:

 <gmp-place-search>
  <gmp-place-text-search-request
    text-query="QUERY"
  ></gmp-place-text-search-request>
  <gmp-place-content-config>
    <gmp-place-media lightbox-preferred></gmp-place-media>
  </gmp-place-content-config>
</gmp-place-search>

如要使用 Place Search Element,請在 Google Cloud 控制台中,為專案啟用 Places UI Kit API

  
<gmp-place-search
  attribution-position="value-name"
  internal-usage-attribution-ids="space separated strings"
  orientation="value-name"
  selectable
  truncation-preferred>
</gmp-place-search>
const {PlaceSearchElement} = await google.maps.importLibrary("places");
PlaceSearchElement
PlaceSearchElement([options])
參數:
attributionPosition
attr: attribution-position
輸入類型: PlaceSearchAttributionPosition optional
輸出類型: PlaceSearchAttributionPosition
預設值: PlaceSearchAttributionPosition.TOP
歸因標誌和依法揭露按鈕的位置。
HTML 屬性: attribution-position="value-name"
internalUsageAttributionIds
attr: internal-usage-attribution-ids
輸入類型: Iterable<string> optional
輸出類型: Array<string> optional
用來將呼叫歸因於特定套件或 OSS 程式庫的 ID。
HTML 屬性: internal-usage-attribution-ids="space separated strings"
orientation
attr: orientation
輸入類型: PlaceSearchOrientation optional
輸出類型: PlaceSearchOrientation
預設值: PlaceSearchOrientation.VERTICAL
元素的方向變體 (垂直或水平)。
HTML 屬性: orientation="value-name"
places
readonly
類型: Array<Place>
唯讀。Place 物件陣列,內含目前顯示地點的 ID、位置和可視區域。
selectable
attr: selectable
輸入類型: boolean optional
輸出類型: boolean
預設值: false
清單項目是否可選取。如果為 true,清單項目會是按鈕,點選時會傳送 gmp-select 事件。此外,也支援無障礙鍵盤導覽和選取。
HTML 屬性: selectable
truncationPreferred
attr: truncation-preferred
輸入類型: boolean optional
輸出類型: boolean
預設值: false
如果設為 true,系統會截斷特定內容行,以便在單行顯示所有內容,而不是換行。
HTML 屬性: truncation-preferred
--gmp-button-border-color
「在地圖中開啟」按鈕的邊框顏色。
--gmp-button-border-radius
「在 Google 地圖中開啟」按鈕的邊框半徑。
--gmp-button-border-width
「在地圖中開啟」按鈕的框線寬度。
--gmp-card-border-radius
地點資訊卡的邊框半徑。
--gmp-dialog-border-radius
Google 地圖揭露事項對話方塊的邊框半徑。
--gmp-mat-color-info
具有資訊情緒的 UI 元素顏色。用於無障礙入口圖示。
--gmp-mat-color-negative
情緒負面 UI 元素的顏色。用於地點營業時間的「休息中」標籤。
--gmp-mat-color-neutral-container
中性填滿 UI 元素的容器顏色。用於評論日期徽章和載入預留位置形狀。
--gmp-mat-color-on-neutral-container
中性容器上的文字和圖示顏色。用於顯示評論日期文字和載入錯誤文字。
--gmp-mat-color-on-secondary-container
文字和圖示的顏色,與次要容器顏色形成對比。用於按鈕文字和圖示。
--gmp-mat-color-on-surface
文字和圖示的顏色,與介面顏色形成對比。用於標題和對話方塊內容。
--gmp-mat-color-on-surface-variant
文字和圖示的低強調色,與 Surface 顏色形成對比。用於地點資訊。
--gmp-mat-color-outline-decorative
非互動式元素的輪廓顏色。用於容器邊框。
--gmp-mat-color-positive
情緒正向的 UI 元素顏色。用於地點營業時間的「營業中」標籤。
--gmp-mat-color-primary
與介面顏色對比的互動式文字和圖示顏色。用於連結、載入指標和總覽圖示。
--gmp-mat-color-secondary-container
相較於介面,填滿顏色較不顯眼。用於按鈕背景。
--gmp-mat-color-surface
背景顏色,用於容器和對話方塊背景。
--gmp-mat-font-body-small
用於地點資訊。
--gmp-mat-font-family
所有文字的基本字型系列。
--gmp-mat-font-headline-medium
用於對話方塊標題。
--gmp-mat-font-label-large
用於按鈕內容。
--gmp-mat-font-title-medium
用於地點名稱。
--gmp-mat-spacing-extra-small
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-large
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-medium
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-mat-spacing-small
用於元素內的間距,例如文字周圍的邊界和邊框間距。
--gmp-star-rating-color
星級評等中填滿星星的顏色。
--gmp-thumbnail-border-radius
地點縮圖的邊框半徑。
background-color
覆寫元素的背景顏色。
border
覆寫元素的邊框。
border-radius
覆寫元素的邊框半徑。
color-scheme
指出這個元素可採用哪種色彩配置。詳情請參閱color-scheme 說明文件。預設值為 color-scheme: light dark
font-size
縮放元素中的所有文字和圖示。預設值為 16px
已繼承: addEventListenerremoveEventListener
gmp-error
function(event)
引數:
當後端要求遭到拒絕時 (例如 API 金鑰不正確),系統會觸發這項事件。這個事件不會冒泡。
gmp-load
function(event)
引數:
當元素載入並算繪內容時,系統會觸發這個事件。這個事件不會冒泡。
gmp-select
function(event)
引數:
從清單中選取地點時,系統會觸發這個事件。包含 Place 物件,內含所選地點的 ID、位置和檢視區塊。

PlaceSearchElementOptions interface

介面 google.maps.places.PlaceSearchElementOptions

PlaceSearchElement」的選項。

attributionPosition
選填
internalUsageAttributionIds
選填
類型: Iterable<string> optional
用來將呼叫歸因於特定套件或 OSS 程式庫的 ID。
orientation
選填
類型: PlaceSearchOrientation optional
詳情請參閱《PlaceSearchElement.orientation》。
selectable
選填
類型: boolean optional
truncationPreferred
選填
類型: boolean optional

PlaceSearchAttributionPosition 常數

常數 google.maps.places.PlaceSearchAttributionPosition
程式庫 "places"

PlaceSearchElement」的註明內容來源位置。

這些常數也可做為字串使用。在 TypeScript 中,字串常值是由 PlaceSearchAttributionPositionString 型別定義。

const {PlaceSearchAttributionPosition} = await google.maps.importLibrary("places");
BOTTOM PlaceSearchElement 底部的出處資訊
TOP PlaceSearchElement 頂端的歸因資訊

PlaceSearchOrientation 常數

常數 google.maps.places.PlaceSearchOrientation
程式庫 "places"

PlaceSearchElement」的方向變體。

這些常數也可做為字串使用。在 TypeScript 中,字串常值是由 PlaceSearchOrientationString 型別定義。

const {PlaceSearchOrientation} = await google.maps.importLibrary("places");
HORIZONTAL 橫向螢幕方向。
VERTICAL 直向。

PlaceSelectEvent class

class google.maps.places.PlaceSelectEvent extends Event
library "places"

從地點清單中選取地點時,系統會觸發這個事件。您可以使用 event.place 存取所選地點。

const {PlaceSelectEvent} = await google.maps.importLibrary("places");
place
readonly
類型: Place
所選地點。

PlaceNearbySearchRequestElement class

class google.maps.places.PlaceNearbySearchRequestElement extends HTMLElement implements PlaceNearbySearchRequestElementOptions
library "places"

設定 PlaceSearchElement,根據附近的搜尋要求載入結果。搜尋元素必須有 locationRestriction 屬性才能載入。如未設定 locationRestriction,系統會忽略所有其他已設定的屬性。將這個元素附加為 PlaceSearchElement 的子項,即可載入結果。例如:

 <gmp-place-search>
  <gmp-place-nearby-search-request
    location-restriction="RADIUS@LAT,LNG"
  ></gmp-place-nearby-search-request>
  <gmp-place-content-config>
    <gmp-place-media lightbox-preferred></gmp-place-media>
  </gmp-place-content-config>
</gmp-place-search>

      
<gmp-place-nearby-search-request
  excluded-primary-types="excluded-primary-type1 excluded-primary-type2..."
  excluded-types="excluded-type1 excluded-type2..."
  included-primary-types="included-primary-type1 included-primary-type2..."
  included-types="included-type1 included-type2..."
  location-restriction="radius@lat,lng"
  max-result-count="number"
  rank-preference="value-name">
</gmp-place-nearby-search-request>
const {PlaceNearbySearchRequestElement} = await google.maps.importLibrary("places");
PlaceNearbySearchRequestElement
PlaceNearbySearchRequestElement([options])
參數:
excludedPrimaryTypes
attr: excluded-primary-types
輸入類型: Array<string> optional
輸出類型: Array<string> optional
預設值: null
排除的主要地點類型。
HTML 屬性: excluded-primary-types="excluded-primary-type1 excluded-primary-type2..."
excludedTypes
attr: excluded-types
輸入類型: Array<string> optional
輸出類型: Array<string> optional
預設值: null
排除的地點類型。
HTML 屬性: excluded-types="excluded-type1 excluded-type2..."
futureOpeningBusinessesIncluded
輸入類型: boolean optional
輸出類型: boolean optional
為尚未開幕但預計在未來開幕的商家提供地點預測。
includedPrimaryTypes
attr: included-primary-types
輸入類型: Array<string> optional
輸出類型: Array<string> optional
預設值: null
包含主要地點類型。
HTML 屬性: included-primary-types="included-primary-type1 included-primary-type2..."
includedTypes
attr: included-types
輸入類型: Array<string> optional
輸出類型: Array<string> optional
預設值: null
納入的地點類型。
HTML 屬性: included-types="included-type1 included-type2..."
locationRestriction
attr: location-restriction
輸入類型: Circle|CircleLiteral optional
輸出類型: Circle optional
預設值: null
要搜尋的區域。正規化為 Circle
HTML 屬性: location-restriction="radius@lat,lng"
maxResultCount
attr: max-result-count
輸入類型: number optional
輸出類型: number optional
預設值: null
要傳回的結果數上限。
HTML 屬性: max-result-count="number"
rankPreference
attr: rank-preference
輸入類型: SearchNearbyRankPreference optional
輸出類型: SearchNearbyRankPreference optional
預設值: null
回覆中結果的排序方式。
HTML 屬性: rank-preference="value-name"
已繼承: addEventListenerremoveEventListener

PlaceNearbySearchRequestElementOptions 介面

介面 google.maps.places.PlaceNearbySearchRequestElementOptions

PlaceNearbySearchRequestElement」的選項。

excludedPrimaryTypes
選填
類型: Array<string> optional
excludedTypes
選填
類型: Array<string> optional
futureOpeningBusinessesIncluded
選填
類型: boolean optional
為尚未開幕但預計在未來開幕的商家提供地點預測。
includedPrimaryTypes
選填
類型: Array<string> optional
includedTypes
選填
類型: Array<string> optional
locationRestriction
選填
類型: Circle|CircleLiteral optional
maxResultCount
選填
類型: number optional
要傳回的結果數上限。詳情請參閱 PlaceNearbySearchRequestElement.maxResultCountSearchNearbyRequest.maxResultCount
rankPreference
選填
類型: SearchNearbyRankPreference optional
回覆中結果的排序方式。詳情請參閱 PlaceNearbySearchRequestElement.rankPreferenceSearchNearbyRankPreference

PlaceTextSearchRequestElement class

class google.maps.places.PlaceTextSearchRequestElement extends HTMLElement implements PlaceTextSearchRequestElementOptions
library "places"

設定 PlaceSearchElement,根據文字搜尋要求載入結果。搜尋元素必須有 textQuery 屬性才能載入。如未設定 textQuery,系統會忽略所有其他已設定的屬性。將這個元素附加為 PlaceSearchElement 的子項,即可載入結果。例如:

 <gmp-place-search>
  <gmp-place-text-search-request
    text-query="QUERY"
  ></gmp-place-text-search-request>
  <gmp-place-content-config>
    <gmp-place-media lightbox-preferred></gmp-place-media>
  </gmp-place-content-config>
</gmp-place-search>

         
<gmp-place-text-search-request
  ev-connector-types="ev-connector-type1 ev-connector-type2..."
  ev-minimum-charging-rate-kw="number"
  included-type="type"
  is-open-now
  location-bias="lat,lng"
  location-restriction="southwest-lat,southwest-lng|northeast-lat,northeast-lng"
  max-result-count="number"
  min-rating="number"
  price-levels="price-level1 price-level2..."
  rank-preference="value-name"
  text-query="string"
  use-strict-type-filtering>
</gmp-place-text-search-request>
const {PlaceTextSearchRequestElement} = await google.maps.importLibrary("places");
PlaceTextSearchRequestElement
PlaceTextSearchRequestElement([options])
參數:
evConnectorTypes
attr: ev-connector-types
輸入類型: Array<EVConnectorType> optional
輸出類型: Array<EVConnectorType> optional
預設值: null
偏好的電動車充電插頭類型清單。
HTML 屬性: ev-connector-types="ev-connector-type1 ev-connector-type2..."
evMinimumChargingRateKw
attr: ev-minimum-charging-rate-kw
輸入類型: number optional
輸出類型: number optional
預設值: null
以千瓦為單位的最低充電速率。
HTML 屬性: ev-minimum-charging-rate-kw="number"
futureOpeningBusinessesIncluded
輸入類型: boolean optional
輸出類型: boolean optional
為尚未開幕但預計在未來開幕的商家提供地點預測。
includedType
attr: included-type
輸入類型: string optional
輸出類型: string optional
預設值: null
要求的地點類型。
HTML 屬性: included-type="type"
isOpenNow
attr: is-open-now
輸入類型: boolean optional
輸出類型: boolean optional
預設值: null
用於將搜尋範圍限制在目前營業中的地點。
HTML 屬性: is-open-now
locationBias
attr: location-bias
輸入類型: LocationBias optional
輸出類型: LatLngAltitude|LatLngBounds|Circle|string optional
預設值: null
搜尋的位置自訂調整設定。
HTML 屬性:
  • location-bias="lat,lng"
  • location-bias="lat,lng[,altitude]"
  • location-bias="swlat,swlng|nelat,nelng"
  • location-bias="radius@lat,lng"
  • location-bias="IP_BIAS"
locationRestriction
attr: location-restriction
輸入類型: LatLngBounds|LatLngBoundsLiteral optional
輸出類型: LatLngBounds optional
預設值: null
搜尋的地點限制。正規化為 LatLngBounds
HTML 屬性: location-restriction="southwest-lat,southwest-lng|northeast-lat,northeast-lng"
maxResultCount
attr: max-result-count
輸入類型: number optional
輸出類型: number optional
預設值: null
要傳回的結果數上限。
HTML 屬性: max-result-count="number"
minRating
attr: min-rating
輸入類型: number optional
輸出類型: number optional
預設值: null
篩除平均使用者評分嚴格低於此上限的結果。
HTML 屬性: min-rating="number"
priceLevels
attr: price-levels
輸入類型: Array<PriceLevel> optional
輸出類型: Array<PriceLevel> optional
預設值: null
用於將搜尋範圍限制在標示為特定價位的地點。
HTML 屬性: price-levels="price-level1 price-level2..."
rankPreference
attr: rank-preference
輸入類型: SearchByTextRankPreference optional
輸出類型: SearchByTextRankPreference optional
預設值: null
回覆中結果的排序方式。
HTML 屬性: rank-preference="value-name"
textQuery
attr: text-query
輸入類型: string optional
輸出類型: string optional
預設值: null
文字搜尋的查詢文字。
HTML 屬性: text-query="string"
useStrictTypeFiltering
attr: use-strict-type-filtering
輸入類型: boolean optional
輸出類型: boolean optional
預設值: null
用於為「includedType」設定嚴格的類型篩選條件。
HTML 屬性: use-strict-type-filtering
已繼承: addEventListenerremoveEventListener

PlaceTextSearchRequestElementOptions 介面

介面 google.maps.places.PlaceTextSearchRequestElementOptions

PlaceTextSearchRequestElement」的選項。

evConnectorTypes
選填
類型: Array<EVConnectorType> optional
偏好的電動車充電插頭類型清單。詳情請參閱 SearchByTextRequest.evSearchOptionsPlaceTextSearchRequestElement.evConnectorTypes
evMinimumChargingRateKw
選填
類型: number optional
以千瓦為單位的最低充電速率。詳情請參閱 SearchByTextRequest.evSearchOptionsPlaceTextSearchRequestElement.evMinimumChargingRateKw
futureOpeningBusinessesIncluded
選填
類型: boolean optional
為尚未開幕但預計在未來開幕的商家提供地點預測。
includedType
選填
類型: string optional
isOpenNow
選填
類型: boolean optional
用於將搜尋範圍限制在目前營業中的地點。詳情請參閱 SearchByTextRequest.isOpenNowPlaceTextSearchRequestElement.isOpenNow
locationBias
選填
類型: LocationBias optional
locationRestriction
選填
maxResultCount
選填
類型: number optional
要傳回的結果數上限。詳情請參閱 SearchByTextRequest.maxResultCountPlaceTextSearchRequestElement.maxResultCount
minRating
選填
類型: number optional
篩除平均使用者評分嚴格低於此限制的結果。詳情請參閱 SearchByTextRequest.minRatingPlaceTextSearchRequestElement.minRating
priceLevels
選填
類型: Array<PriceLevel> optional
用於將搜尋範圍限制在標示為特定價位的地點。詳情請參閱 SearchByTextRequest.priceLevelsPlaceTextSearchRequestElement.priceLevels
rankPreference
選填
類型: SearchByTextRankPreference optional
回覆中結果的排序方式。詳情請參閱 SearchByTextRequest.rankPreferencePlaceTextSearchRequestElement.rankPreference
textQuery
選填
類型: string optional
文字搜尋的查詢文字。詳情請參閱 SearchByTextRequest.textQueryPlaceTextSearchRequestElement.textQuery
useStrictTypeFiltering
選填
類型: boolean optional

自動完成 類別

class google.maps.places.Autocomplete extends MVCObject
library "places"

這個小工具會根據使用者輸入的文字提供地點預測結果。它會附加至 text 類型的輸入元素,並監聽該欄位中的文字輸入內容。預測結果清單會以下拉式清單的形式呈現,並在使用者輸入文字時更新。

const {Autocomplete} = await google.maps.importLibrary("places");
Autocomplete
Autocomplete(inputField[, opts])
參數:
建立 Autocomplete 的新例項,並使用指定選項附加至指定輸入文字欄位。
getBounds
getBounds()
參數:
傳回值: LatLngBounds|undefined 偏差範圍。
傳回預測結果的偏誤範圍。
getFields
getFields()
參數:
傳回值: Array<string>|undefined
成功擷取詳細資料時,傳回要納入地點詳細資料回應的欄位。如需欄位清單,請參閱 PlaceResult
getPlace
getPlace()
參數:
傳回值: PlaceResult 使用者選取的地點。
如果成功擷取詳細資料,系統會傳回使用者選取的地點詳細資料。否則會傳回 Place 虛設常式物件,且 name 屬性會設為輸入欄位的目前值。
setBounds
setBounds(bounds)
參數:
傳回值:
設定偏好的區域,以便傳回地點結果。結果可能會優先 (但不限於) 顯示這個區域的地點。
setComponentRestrictions
setComponentRestrictions(restrictions)
參數:
傳回值:
設定元件限制。元件限制用於將預測結果限制在父項元件內。例如國家/地區。
setFields
setFields(fields)
參數:
  • fields: Array<string> optional
傳回值:
設定成功擷取詳細資料時,要在詳細資料回應中納入的地點欄位。如需欄位清單,請參閱 PlaceResult
setOptions
setOptions(options)
參數:
傳回值:
setTypes
setTypes(types)
參數:
  • types: Array<string> optional 要納入的預測類型。
傳回值:
設定要傳回的預測類型。如需支援的類型,請參閱 開發人員指南。如未指定類型,系統會傳回所有類型。
已繼承: addListenerbindTogetnotifysetsetValuesunbindunbindAll
place_changed
function()
引數:
當使用者選取的地點提供 PlaceResult 時,系統會觸發這項事件。
如果使用者輸入的 Place 名稱並非控制項建議的名稱,然後按下 Enter 鍵,或是 Place Details 要求失敗,則 PlaceResult 會在 name 屬性中包含使用者輸入的內容,且不會定義其他屬性。

AutocompleteOptions 介面

介面 google.maps.places.AutocompleteOptions

可在 Autocomplete 物件上設定的選項。

bounds
選填
要搜尋地點的區域。
componentRestrictions
選填
類型: ComponentRestrictions optional
元件限制。元件限制用於將預測結果限制在父項元件內。例如國家/地區。
fields
選填
類型: Array<string> optional
成功擷取詳細資料時,詳細資料回應中要納入的 Place 欄位,這些欄位會產生費用。如果傳入 ['ALL'],系統會傳回所有可用的欄位並據此收費 (不適用於實際工作環境部署作業)。如需欄位清單,請參閱 PlaceResult。巢狀欄位可使用點路徑指定 (例如 "geometry.location")。預設值為 ['ALL']
placeIdOnly
選填
類型: boolean optional
是否只擷取地點 ID。觸發 place_changed 事件時,可用的 PlaceResult 只會包含 place_id、types 和 name 欄位,以及 Autocomplete 服務傳回的 place_id、types 和 description。預設為停用。
strictBounds
選填
類型: boolean optional
布林值,表示 Autocomplete 小工具在傳送查詢時,應只傳回 Autocomplete 小工具邊界內的地點。將 strictBounds 設為 false (預設值) 後,結果可能會優先 (但不限於) 顯示邊界內的地點。
types
選填
類型: Array<string> optional
要傳回的預測類型。如需支援的類型,請參閱 開發人員指南。如未指定類型,系統會傳回所有類型。

class google.maps.places.SearchBox extends MVCObject
library "places"

這個小工具會根據使用者輸入的文字提供查詢預測結果。它會附加至 text 類型的輸入元素,並監聽該欄位中的文字輸入內容。預測結果清單會以下拉式清單的形式呈現,並在輸入文字時更新。

const {SearchBox} = await google.maps.importLibrary("places");
SearchBox
SearchBox(inputField[, opts])
參數:
建立 SearchBox 的新例項,並使用指定選項附加至指定輸入文字欄位。
getBounds
getBounds()
參數:
傳回值: LatLngBounds|undefined
傳回查詢預測結果的偏誤範圍。
getPlaces
getPlaces()
參數:
傳回值: Array<PlaceResult>|undefined
傳回使用者選取的查詢,以搭配 places_changed 事件使用。
setBounds
setBounds(bounds)
參數:
傳回值:
設定用於查詢預測的區域。結果只會偏向這個區域,不會完全限制於此。
已繼承: addListenerbindTogetnotifysetsetValuesunbindunbindAll
places_changed
function()
引數:
使用者選取查詢時會觸發此事件,getPlaces 則用於取得新地點。

SearchBoxOptions interface

介面 google.maps.places.SearchBoxOptions

可在 SearchBox 物件上設定的選項。

bounds
選填
要將查詢預測結果偏向的區域。預測結果可能會優先 (但不限於) 顯示這些邊界內的地點。

PlaceContextualElement class

class google.maps.places.PlaceContextualElement extends HTMLElement implements PlaceContextualElementOptions
library "places"

這個小工具會使用脈絡詞元,顯示「利用 Google 地圖建立基準」回覆的情境式檢視。

<gmp-place-contextual
  context-token="string">
</gmp-place-contextual>
const {PlaceContextualElement} = await google.maps.importLibrary("places");
PlaceContextualElement
PlaceContextualElement([options])
參數:
contextToken
attr: context-token
輸入類型: string optional
輸出類型: string optional
內容比對權杖。
HTML 屬性: context-token="string"
已繼承: addEventListenerremoveEventListener

PlaceContextualElementOptions 介面

介面 google.maps.places.PlaceContextualElementOptions

PlaceContextualElement」的選項。

contextToken
選填
類型: string optional
利用 Google 地圖建立基準回應提供的脈絡權杖。

PlaceContextualListConfigElement class

class google.maps.places.PlaceContextualListConfigElement extends HTMLElement implements PlaceContextualListConfigElementOptions
library "places"

HTML 元素,可設定地點情境元素清單檢視畫面的選項。

<gmp-place-contextual-list-config
  layout="value-name"
  map-hidden>
</gmp-place-contextual-list-config>
const {PlaceContextualListConfigElement} = await google.maps.importLibrary("places");
PlaceContextualListConfigElement
PlaceContextualListConfigElement([options])
參數:
layout
attr: layout
輸入類型: PlaceContextualListLayout optional
輸出類型: PlaceContextualListLayout
版面配置。
HTML 屬性: layout="value-name"
mapHidden
attr: map-hidden
輸入類型: boolean optional
輸出類型: boolean
地圖是否隱藏。
HTML 屬性: map-hidden
已繼承: addEventListenerremoveEventListener

PlaceContextualListConfigElementOptions 介面

介面 google.maps.places.PlaceContextualListConfigElementOptions

PlaceContextualListConfigElement 的選項。

layout
選填
類型: PlaceContextualListLayout optional
版面配置。
mapHidden
選填
類型: boolean optional
預設值: false
是否應隱藏地圖。

PlaceContextualListLayout 常數

常數 google.maps.places.PlaceContextualListLayout
程式庫 "places"

地點內容元素支援清單檢視畫面的版面配置清單。

這些常數也可做為字串使用。在 TypeScript 中,字串常值是由 PlaceContextualListLayoutString 型別定義。

const {PlaceContextualListLayout} = await google.maps.importLibrary("places");
COMPACT 精簡清單版面配置:清單項目會以單行連結的形式呈現,溢位項目則會顯示在下拉式清單中。
VERTICAL 直向清單版面配置:清單項目會以直向清單中的資訊卡形式呈現。