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 雙字元區域代碼。空白集合不會限制結果。如果同時設定 locationRestriction 和 includedRegionCodes,結果會位於交集區域。
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。行為與輸入內容的 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 中有任何額外文字,則會位於 prediction-item-main-text 之外,並沿用 prediction-item 的樣式。在預設情況下會以灰色顯示。這組額外文字通常是地址。
prediction-item-match
傳回的預測查詢字串中,與使用者輸入文字相符的部分。根據預設,這組相符文字會以粗體字標示。請注意,相符文字只會在 prediction-item-main-text 中醒目顯示。
prediction-item-nonmatch
預測結果主要文字中,與使用者輸入內容不符的部分。
prediction-item-secondary-text
prediction-item 的一部分,是預測結果的次要文字。這組額外文字通常是地址。
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
覆寫元素的字型。
繼承: addEventListener、removeEventListener
gmp-error
function(errorEvent)
引數:
  • errorEvent: Event optional
如果對後端的要求遭拒 (例如 API 金鑰不正確),就會觸發這個事件。這個事件不會向上傳遞。
gmp-select
function(placePredictionSelectEvent)
引數:
使用者選取地點預測字串時,就會觸發這個事件。包含可轉換為 Place 物件的 PlacePrediction 物件。

PlaceAutocompleteElementOptions 介面

介面 google.maps.places.PlaceAutocompleteElementOptions
由 PlaceAutocompleteElement 實作

建構 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 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 雙字元區域代碼。空白集合不會限制結果。如果同時設定 locationRestriction 和 includedRegionCodes,結果會位於交集區域。
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。行為與輸入內容的 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 中有任何額外文字,則會位於 prediction-item-main-text 之外,並沿用 prediction-item 的樣式。在預設情況下會以灰色顯示。這組額外文字通常是地址。
prediction-item-match
傳回的預測查詢字串中,與使用者輸入文字相符的部分。根據預設,這組相符文字會以粗體字標示。請注意,相符文字只會在 prediction-item-main-text 中醒目顯示。
prediction-item-nonmatch
預測結果主要文字中,與使用者輸入內容不符的部分。
prediction-item-secondary-text
prediction-item 的一部分,是預測結果的次要文字。這組額外文字通常是地址。
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
覆寫元素的字型。
繼承: addEventListener、removeEventListener
gmp-error
function(errorEvent)
引數:
  • errorEvent: Event optional
如果對後端的要求遭拒 (例如 API 金鑰不正確),就會觸發這個事件。這個事件不會向上傳遞。
gmp-select
function(placeSelectEvent)
引數:
使用者選取地點預測字串時,就會觸發這個事件。包含 Place 物件。

BasicPlaceAutocompleteElementOptions 介面

介面 google.maps.places.BasicPlaceAutocompleteElementOptions
由 BasicPlaceAutocompleteElement 實作

建構 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 google.maps.places.PlaceDetailsElement extends HTMLElement implements PlaceDetailsElementOptions
extended by AdvancedPlaceDetailsElement
library "places"

以完整版面配置顯示地點詳細資料。附加 PlaceDetailsPlaceRequestElement 或 PlaceDetailsLocationRequestElement,指定要顯示的地點。附加 PlaceContentConfigElement、PlaceStandardContentElement 或 PlaceAllContentElement,指定要算繪的內容。

範例:

 <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
唯讀。Place 物件,包含目前算繪地點的 ID、位置和可視區域。
--gmp-button-border-color
「在 Google 地圖中開啟」按鈕的框線顏色。
--gmp-button-border-radius
「在 Google 地圖中開啟」按鈕的邊框半徑。
--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
用於文字和圖示的低強調色,可與任何表面色搭配。用於較不強調的文字。
--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 地圖揭露事項對話方塊中的地點地址、評分、類型、價格、目前營業狀態、營業時間、評論、電話號碼、網站、Plus Code、主要特色和內文。
--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
縮放元素中的所有文字和圖示,這些文字和圖示在內部以 ems 定義。預設值為 16px。
繼承: addEventListener、removeEventListener
gmp-error
function(event)
引數:
如果對後端的要求遭拒 (例如 API 金鑰不正確),就會觸發這個事件。這個事件不會向上傳遞。
gmp-load
function(event)
引數:
元素載入並算繪內容時,就會觸發這個事件。這個事件不會向上傳遞。

PlaceDetailsElementOptions 介面

介面 google.maps.places.PlaceDetailsElementOptions
由 AdvancedPlaceDetailsElementOptions 擴充
由 AdvancedPlaceDetailsElement, PlaceDetailsElement 實作

「PlaceDetailsElement」的選項。

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

PlaceDetailsCompactElement 類別

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

以精簡版面配置顯示地點詳細資料。附加 PlaceDetailsPlaceRequestElement 或 PlaceDetailsLocationRequestElement,指定要算繪的地點。附加 PlaceContentConfigElement、PlaceStandardContentElement 或 PlaceAllContentElement,指定要算繪的內容。

範例:

 <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
唯讀。Place 物件,包含目前算繪地點的 ID、位置和可視區域。
truncationPreferred
attr: truncation-preferred
輸入類型: boolean optional
輸出類型: boolean
預設值: false
如果設為 true,系統會截斷地點名稱和地址,使其顯示在同一行,而不是換行。
HTML 屬性: truncation-preferred
--gmp-button-border-color
「在 Google 地圖中開啟」按鈕的框線顏色。
--gmp-button-border-radius
「在 Google 地圖中開啟」按鈕的邊框半徑。
--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
用於文字和圖示的低強調色,可與任何表面色搭配。用於較不強調的文字。
--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
縮放元素中的所有文字和圖示,這些文字和圖示在內部以 ems 定義。預設值為 16px。
繼承: addEventListener、removeEventListener
gmp-error
function(event)
引數:
如果對後端的要求遭拒 (例如 API 金鑰不正確),就會觸發這個事件。這個事件不會向上傳遞。
gmp-load
function(event)
引數:
元素載入並算繪內容時,就會觸發這個事件。這個事件不會向上傳遞。

PlaceDetailsCompactElementOptions 介面

介面 google.maps.places.PlaceDetailsCompactElementOptions
由 AdvancedPlaceDetailsCompactElementOptions 擴充
由 AdvancedPlaceDetailsCompactElement, PlaceDetailsCompactElement 實作

「PlaceDetailsCompactElement」的選項。

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

AdvancedPlaceDetailsElement 類別

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

以完整版面配置顯示地點詳細資料。附加 PlaceDetailsPlaceRequestElement 或 PlaceDetailsLocationRequestElement,指定要顯示的地點。直接附加 PlaceStandardContentElement、PlaceAllContentElement 或 Place Details 元素,即可設定要算繪的內容。

範例:

 <gmp-advanced-place-details>
  <gmp-place-details-place-request
    place="PLACE_ID"
  ></gmp-place-details-place-request>
  <gmp-place-standard-content>
  </gmp-place-standard-content>
</gmp-advanced-place-details>

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

<gmp-advanced-place-details
  internal-usage-attribution-ids="space separated strings">
</gmp-advanced-place-details>
const {AdvancedPlaceDetailsElement} = await google.maps.importLibrary("places");
AdvancedPlaceDetailsElement
AdvancedPlaceDetailsElement([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
唯讀。Place 物件,包含目前算繪地點的 ID、位置和可視區域。
action-corner
action-main
Alphabasic-section-bottom
自訂 HTML 內容的版位,顯示在基本資訊區段底部,主要動作按鈕正下方。
Alphabasic-section-top
自訂 HTML 內容的版位,顯示在基本資訊部分,就在地點名稱正上方。
繼承: --gmp-button-border-color、 --gmp-button-border-radius、 --gmp-button-border-width、 --gmp-collage-border-radius-outer、 --gmp-dialog-border-radius、 --gmp-mat-color-disabled-surface、 --gmp-mat-color-info、 --gmp-mat-color-negative、 --gmp-mat-color-neutral-container、 --gmp-mat-color-on-neutral-container、 --gmp-mat-color-on-positive-container、 --gmp-mat-color-on-secondary-container、 --gmp-mat-color-on-surface、 --gmp-mat-color-on-surface-variant、 --gmp-mat-color-outline-decorative、 --gmp-mat-color-positive、 --gmp-mat-color-positive-container、 --gmp-mat-color-primary、 --gmp-mat-color-secondary-container、 --gmp-mat-color-surface、 --gmp-mat-font-body-medium、 --gmp-mat-font-body-small、 --gmp-mat-font-display-small、 --gmp-mat-font-family、 --gmp-mat-font-headline-medium、 --gmp-mat-font-label-large、 --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、 font-size
繼承: addEventListener、removeEventListener
繼承: gmp-error、gmp-load

AdvancedPlaceDetailsElementOptions 介面

interface google.maps.places.AdvancedPlaceDetailsElementOptions extends PlaceDetailsElementOptions
implemented by AdvancedPlaceDetailsElement

「AdvancedPlaceDetailsElement」的選項。

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

AdvancedPlaceDetailsCompactElement 類別

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

以精簡版面配置顯示地點詳細資料。附加 PlaceDetailsPlaceRequestElement 或 PlaceDetailsLocationRequestElement,指定要算繪的地點。附加 PlaceStandardContentElement、PlaceAllContentElement 或指定特定內容子項,即可設定要算繪的內容。

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

<gmp-advanced-place-details-compact
  internal-usage-attribution-ids="space separated strings">
</gmp-advanced-place-details-compact>
const {AdvancedPlaceDetailsCompactElement} = await google.maps.importLibrary("places");
AdvancedPlaceDetailsCompactElement
AdvancedPlaceDetailsCompactElement([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
唯讀。Place 物件,包含目前算繪地點的 ID、位置和可視區域。
繼承: orientation (attr:orientation)、 truncationPreferred (attr:truncation-preferred)
action-corner
action-main
Alphabasic-section-bottom
自訂 HTML 內容的版位,顯示在基本資訊區段底部,主要動作按鈕正下方。
Alphabasic-section-top
自訂 HTML 內容的版位,顯示在基本資訊部分,就在地點名稱正上方。
繼承: --gmp-button-border-color、 --gmp-button-border-radius、 --gmp-button-border-width、 --gmp-dialog-border-radius、 --gmp-mat-color-info、 --gmp-mat-color-negative、 --gmp-mat-color-neutral-container、 --gmp-mat-color-on-secondary-container、 --gmp-mat-color-on-surface、 --gmp-mat-color-on-surface-variant、 --gmp-mat-color-outline-decorative、 --gmp-mat-color-positive、 --gmp-mat-color-primary、 --gmp-mat-color-secondary-container、 --gmp-mat-color-surface、 --gmp-mat-font-body-medium、 --gmp-mat-font-body-small、 --gmp-mat-font-family、 --gmp-mat-font-headline-medium、 --gmp-mat-font-label-large、 --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、 font-size
繼承: addEventListener、removeEventListener
繼承: gmp-error、gmp-load

AdvancedPlaceDetailsCompactElementOptions 介面

interface google.maps.places.AdvancedPlaceDetailsCompactElementOptions extends PlaceDetailsCompactElementOptions
implemented by AdvancedPlaceDetailsCompactElement

「AdvancedPlaceDetailsCompactElement」的選項。

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

PlaceDetailsOrientation 常數

constants google.maps.places.PlaceDetailsOrientation
library "places"

PlaceDetailsCompactElement 的方向變化版本。

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

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

PlaceDetailsPlaceRequestElement 類別

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

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

 <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/###"
繼承: addEventListener、removeEventListener

PlaceDetailsPlaceRequestElementOptions 介面

介面 google.maps.places.PlaceDetailsPlaceRequestElementOptions
由 PlaceDetailsPlaceRequestElement 實作

「PlaceDetailsPlaceRequestElement」的選項。

place
選填
類型: Place|string optional

PlaceDetailsLocationRequestElement 類別

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

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

 <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"
繼承: addEventListener、removeEventListener

PlaceDetailsLocationRequestElementOptions 介面

介面 google.maps.places.PlaceDetailsLocationRequestElementOptions
由 PlaceDetailsLocationRequestElement 實作

「PlaceDetailsLocationRequestElement」的選項。

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

PlaceSearchElement 類別

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

以清單形式顯示地點搜尋結果。附加 PlaceTextSearchRequestElement 或 PlaceNearbySearchRequestElement,指定要算繪結果的要求。附加 PlaceContentConfigElement、PlaceStandardContentElement 或 PlaceAllContentElement,指定要算繪的內容。

範例:

 <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 元素,請在 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
「在 Google 地圖中開啟」按鈕的邊框顏色。
--gmp-button-border-radius
「在 Google 地圖中開啟」按鈕的邊框半徑。
--gmp-button-border-width
「在 Google 地圖中開啟」按鈕的框線寬度。
--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
文字和圖示的低強調色,與表面色形成對比。用於提供地點資訊。
--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。
繼承: addEventListener、removeEventListener
gmp-error
function(event)
引數:
如果對後端的要求遭拒 (例如 API 金鑰不正確),就會觸發這個事件。這個事件不會向上傳遞。
gmp-load
function(event)
引數:
元素載入並算繪內容時,就會觸發這個事件。這個事件不會向上傳遞。
gmp-select
function(event)
引數:
從清單中選取地點時,就會觸發這個事件。包含 Place 物件,其中含有選取地點的 ID、位置和可視區域。

PlaceSearchElementOptions 介面

介面 google.maps.places.PlaceSearchElementOptions
由 AdvancedPlaceSearchElementOptions 擴充
由 AdvancedPlaceSearchElement, PlaceSearchElement 實作

「PlaceSearchElement」的選項。

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

PlaceItemElement 類別

class google.maps.places.PlaceItemElement extends HTMLElement implements PlaceItemElementOptions
extended by AdvancedPlaceItemElement
library "places"

地點清單項目的公開網頁元件包裝函式 (<gmp-place-item>)。<gmp-place-item> 自訂元素會在 <gmp-place-search> 內,算繪個別地點結果資訊卡。每個 <gmp-place-item> 都會顯示地點資訊,由 Places UI Kit 的子項視覺元件組成。

<gmp-place-item></gmp-place-item>
const {PlaceItemElement} = await google.maps.importLibrary("places");
繼承: addEventListener、removeEventListener

PlaceItemElementOptions 介面

介面 google.maps.places.PlaceItemElementOptions
由 AdvancedPlaceItemElementOptions 擴充
由 AdvancedPlaceItemElement, PlaceItemElement 實作

「PlaceItemElement」的選項。

AdvancedPlaceSearchElement 類別

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

以清單形式顯示進階地點搜尋結果。附加 PlaceTextSearchRequestElement 或 PlaceNearbySearchRequestElement,指定要算繪結果的要求。附加 PlaceStandardContentElement、PlaceAllContentElement 或 <template slot="details-item">,指定要算繪的內容。

範例:

 <gmp-advanced-place-search>
  <gmp-place-text-search-request
    text-query="QUERY"
  ></gmp-place-text-search-request>
  <template slot="details-item">
    <gmp-place-media lightbox-preferred></gmp-place-media>
  </template>
</gmp-advanced-place-search>

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

<gmp-advanced-place-search
  attribution-position="value-name"
  internal-usage-attribution-ids="space separated strings"
  orientation="value-name"
  selectable
  truncation-preferred>
</gmp-advanced-place-search>
const {AdvancedPlaceSearchElement} = await google.maps.importLibrary("places");
AdvancedPlaceSearchElement
AdvancedPlaceSearchElement([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"
selectable
attr: selectable
輸入類型: boolean optional
輸出類型: boolean
預設值: false
是否可選取清單項目。如果設為 true,清單項目會是按鈕,點選後會調度 gmp-select 事件。此外,也支援無障礙鍵盤瀏覽和選取功能。
HTML 屬性: selectable
truncationPreferred
attr: truncation-preferred
輸入類型: boolean optional
輸出類型: boolean
預設值: false
如果設為 true,系統會截斷特定內容行,使其符合單行長度,而不是換行。
HTML 屬性: truncation-preferred
沿用: places
details-item
HTML 範本,其中包含 gmp-place Place Widgets,用於轉譯搜尋結果中的每個地點。
--gmp-button-border-color
「在 Google 地圖中開啟」按鈕的邊框顏色。
--gmp-button-border-radius
「在 Google 地圖中開啟」按鈕的邊框半徑。
--gmp-button-border-width
「在 Google 地圖中開啟」按鈕的框線寬度。
--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
文字和圖示的低強調色,與表面色形成對比。用於提供地點資訊。
--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。
繼承: addEventListener、removeEventListener
gmp-error
function(event)
引數:
如果對後端的要求遭拒 (例如 API 金鑰不正確),就會觸發這個事件。這個事件不會向上傳遞。
gmp-load
function(event)
引數:
元素載入並算繪內容時,就會觸發這個事件。這個事件不會向上傳遞。
gmp-select
function(event)
引數:
從清單中選取地點時,就會觸發這個事件。包含 Place 物件,其中含有選取地點的 ID、位置和可視區域。

AdvancedPlaceSearchElementOptions 介面

interface google.maps.places.AdvancedPlaceSearchElementOptions extends PlaceSearchElementOptions
implemented by AdvancedPlaceSearchElement

「AdvancedPlaceSearchElement」的選項。

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

AdvancedPlaceListElement 類別

class google.maps.places.AdvancedPlaceListElement extends HTMLElement implements AdvancedPlaceListElementOptions
library "places"

以清單形式顯示地點搜尋結果。附加一或多個 PlaceDetailsPlaceRequestElement,或設定 places 屬性,指定要顯示的地點。附加 PlaceStandardContentElement 或 PlaceAllContentElement,指定要算繪的內容。

範例:

 <gmp-advanced-place-list>
  <gmp-place-details-place-request
    place="PLACE_ID"
  </gmp-place-details-place-request>
  <template slot="details-item">
    <gmp-place-media lightbox-preferred></gmp-place-media>
  </template>
</gmp-advanced-place-list>

如要使用進階地點清單元素,請在 Google Cloud 控制台中為專案啟用 Places UI Kit API。

<gmp-advanced-place-list
  attribution-position="value-name"
  internal-usage-attribution-ids="space separated strings"
  orientation="value-name"
  places="space separated strings"
  selectable
  truncation-preferred>
</gmp-advanced-place-list>
const {AdvancedPlaceListElement} = await google.maps.importLibrary("places");
AdvancedPlaceListElement
AdvancedPlaceListElement([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
attr: places
輸入類型: Iterable<Place|string> optional
輸出類型: Array<Place>
Place 物件清單,包含應在這個元素中顯示的 ID。請注意,如果無法算繪(例如 ID 無效、網路要求錯誤等),系統可能不會顯示在 places 屬性中設定的所有地點。您可以讀取 places 屬性,擷取目前顯示的地點。
HTML 屬性: places="space separated strings"
selectable
attr: selectable
輸入類型: boolean optional
輸出類型: boolean
預設值: false
是否可選取清單項目。如果設為 true,清單項目會是按鈕,點選後會調度 gmp-select 事件。此外,也支援無障礙鍵盤瀏覽和選取功能。
HTML 屬性: selectable
truncationPreferred
attr: truncation-preferred
輸入類型: boolean optional
輸出類型: boolean
預設值: false
如果設為 true,系統會截斷特定內容行,使其符合單行長度,而不是換行。
HTML 屬性: truncation-preferred
details-item
HTML 範本,內含 gmp-place Place Widgets,用於轉譯清單中的每個地點。
--gmp-button-border-color
「在 Google 地圖中開啟」按鈕的邊框顏色。
--gmp-button-border-radius
「在 Google 地圖中開啟」按鈕的邊框半徑。
--gmp-button-border-width
「在 Google 地圖中開啟」按鈕的框線寬度。
--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
文字和圖示的低強調色,與表面色形成對比。用於提供地點資訊。
--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。
繼承: addEventListener、removeEventListener
gmp-error
function(event)
引數:
如果對後端的要求遭拒 (例如 API 金鑰不正確),就會觸發這個事件。這個事件不會向上傳遞。
gmp-load
function(event)
引數:
元素載入並算繪內容時,就會觸發這個事件。這個事件不會向上傳遞。
gmp-select
function(event)
引數:
從清單中選取地點時,就會觸發這個事件。包含 Place 物件,其中含有選取地點的 ID、位置和可視區域。

AdvancedPlaceListElementOptions 介面

介面 google.maps.places.AdvancedPlaceListElementOptions
由 AdvancedPlaceListElement 實作

「AdvancedPlaceListElement」的選項。

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

AdvancedPlaceItemElement 類別

class google.maps.places.AdvancedPlaceItemElement extends PlaceItemElement, HTMLElement implements AdvancedPlaceItemElementOptions, PlaceItemElementOptions
library "places"

進階地點清單項目的公開網頁元件包裝函式 (<gmp-advanced-place-item>)。<gmp-advanced-place-item> 自訂元素會在進階搜尋或集錦容器 (例如 <gmp-advanced-place-search> 或 <gmp-advanced-place-list>) 中,算繪個別的複合式地點搜尋結果資訊卡。每個 <gmp-advanced-place-item> 都會呈現豐富的 Place Details、媒體拼貼、編輯摘要,以及由 Places UI Kit 子視覺元件組成的互動式動作按鈕。

<gmp-advanced-place-item></gmp-advanced-place-item>
const {AdvancedPlaceItemElement} = await google.maps.importLibrary("places");
Alphabasic-section-bottom
自訂 HTML 內容的版位,顯示在基本資訊區段底部,主要動作按鈕正下方。
Alphabasic-section-top
自訂 HTML 內容的版位,顯示在基本資訊部分,就在地點名稱正上方。
繼承: addEventListener、removeEventListener

AdvancedPlaceItemElementOptions 介面

interface google.maps.places.AdvancedPlaceItemElementOptions extends PlaceItemElementOptions
implemented by AdvancedPlaceItemElement

「AdvancedPlaceItemElement」的選項。

PlaceSearchAttributionPosition 常數

constants google.maps.places.PlaceSearchAttributionPosition
library "places"

PlaceSearchElement 的歸因位置。

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

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

PlaceSearchOrientation 常數

constants google.maps.places.PlaceSearchOrientation
library "places"

PlaceSearchElement 的方向變化版本。

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

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

PlaceSelectEvent 類別

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

從地點清單中選取地點時,就會觸發這個事件。使用 event.place 存取所選項目。

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

PlaceNearbySearchRequestElement 類別

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"
繼承: addEventListener、removeEventListener

PlaceNearbySearchRequestElementOptions 介面

介面 google.maps.places.PlaceNearbySearchRequestElementOptions
由 PlaceNearbySearchRequestElement 實作

「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.maxResultCount 和 SearchNearbyRequest.maxResultCount。
rankPreference
選填
類型: SearchNearbyRankPreference optional
回應中結果的排序方式。詳情請參閱 PlaceNearbySearchRequestElement.rankPreference 和 SearchNearbyRankPreference。

PlaceTextSearchRequestElement 類別

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

設定 PlaceSearchElement,根據 Text Search 要求載入結果。必須提供 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
Text Search 的文字查詢。
HTML 屬性: text-query="string"
useStrictTypeFiltering
attr: use-strict-type-filtering
輸入類型: boolean optional
輸出類型: boolean optional
預設值: null
用於為「includedType」設定嚴格的類型篩選。
HTML 屬性: use-strict-type-filtering
繼承: addEventListener、removeEventListener

PlaceTextSearchRequestElementOptions 介面

介面 google.maps.places.PlaceTextSearchRequestElementOptions
由 PlaceTextSearchRequestElement 實作

「PlaceTextSearchRequestElement」的選項。

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

Autocomplete 類別

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
成功擷取詳細資料時,傳回要納入 Place 詳細資料回應的欄位。如需欄位清單,請參閱 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 要納入的預測類型。
傳回值:無
設定要傳回的預測類型。如需支援的類型,請參閱 開發人員指南。如未指定類型,則會傳回所有類型。
繼承: addListener、bindTo、get、notify、set、setValues、unbind、unbindAll
place_changed
function()
引數:無
當使用者選取的地點有 PlaceResult 時,系統會觸發這個事件。
如果使用者輸入的地點名稱不是控制項建議的地點,並按下 Enter 鍵,或 Place Details 要求失敗,PlaceResult 會在 name 屬性中包含使用者輸入內容,且未定義其他屬性。

AutocompleteOptions 介面

介面 google.maps.places.AutocompleteOptions

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

bounds
選填
地點搜尋範圍。
componentRestrictions
選填
類型: ComponentRestrictions optional
元件限制。元件限制可用來將預測結果限制在父項元件內。例如國家/地區。
fields
選填
類型: Array<string> optional
成功擷取詳細資料後,詳細資料回應中要包含的地點欄位,這些欄位會計費。如果傳入 ['ALL'],系統會傳回所有可用的欄位並據此收費 (不建議用於實際工作環境部署作業)。如需欄位清單,請參閱 PlaceResult。巢狀欄位可使用點路徑指定 (例如 "geometry.location")。預設值為 ['ALL']。
placeIdOnly
選填
類型: boolean optional
是否只擷取地點 ID。place_changed 事件觸發時提供的 PlaceResult 只會包含地點 ID、types 和 name 欄位,以及 Autocomplete 服務傳回的地點 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)
參數:
傳回值:無
設定用於偏誤查詢預測的區域。結果只會優先顯示這個區域,不會完全限制在這個區域。
繼承: addListener、bindTo、get、notify、set、setValues、unbind、unbindAll
places_changed
function()
引數:無
使用者選取查詢時,會觸發這個事件,應使用 getPlaces 取得新地點。

SearchBoxOptions 介面

介面 google.maps.places.SearchBoxOptions

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

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

PlaceContextualElement 類別

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"
繼承: addEventListener、removeEventListener

PlaceContextualElementOptions 介面

介面 google.maps.places.PlaceContextualElementOptions
由 PlaceContextualElement 實作

「PlaceContextualElement」的選項。

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

PlaceContextualListConfigElement 類別

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
繼承: addEventListener、removeEventListener

PlaceContextualListConfigElementOptions 介面

介面 google.maps.places.PlaceContextualListConfigElementOptions
由 PlaceContextualListConfigElement 實作

PlaceContextualListConfigElement 的選項。

layout
選填
類型: PlaceContextualListLayout optional
版面配置。
mapHidden
選填
類型: boolean optional
預設值: false
如果應隱藏地圖,則為 True。

PlaceContextualListLayout 常數

constants google.maps.places.PlaceContextualListLayout
library "places"

地點關聯元素支援的清單檢視版面配置清單。

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

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

PlacePinElement 類別

class google.maps.places.PlacePinElement extends HTMLElement implements PlacePinElementOptions
library "places"

使用地點的類別圖示或相片,顯示地點的地圖圖釘。附加 PlaceDetailsPlaceRequestElement 或 PlaceDetailsLocationRequestElement 來指定地點。將圖釘做為 AdvancedMarkerElement 的內容。3D 地圖不支援這項功能。

範例:

 <gmp-advanced-marker>
  <gmp-place-pin>
    <gmp-place-details-place-request
      place="PLACE_ID"
    ></gmp-place-details-place-request>
    <gmp-place-rating></gmp-place-rating>
  </gmp-place-pin>
</gmp-advanced-marker>

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

<gmp-place-pin
  icon="value-name"
  scale="number">
</gmp-place-pin>
const {PlacePinElement} = await google.maps.importLibrary("places");
PlacePinElement
PlacePinElement([options])
參數:
icon
attr: icon
輸入類型: PlacePinIcon optional
輸出類型: PlacePinIcon
預設值: PlacePinIcon.TYPE
圖釘內顯示的圖示。詳情請參閱《PlacePinIcon》。
HTML 屬性: icon="value-name"
photoRendered
readonly
類型: boolean
唯讀。如果圖釘顯示地點的相片,則為 True。如果 icon 不是 PHOTO,則一律為 false。如果 icon 為 PHOTO,但地點沒有相片或相片載入失敗,則此值為 false,圖釘會改為顯示地點類型圖示。在 gmp-load 觸發前設定。
place
readonly
類型: Place optional
唯讀。Place 物件,包含目前算繪地點的 ID、位置和可視區域。如果地點尚未載入或載入失敗,則為 undefined。
scale
attr: scale
輸入類型: number optional
輸出類型: number
預設值: 1
圖釘的大小倍率。
HTML 屬性: scale="number"
default
圖釘上顯示的選用內容,例如 PlaceRatingElement、自訂 <span> 或文字。Light DOM 子項會直接插入圖釘。內容顯示位置取決於 icon:TYPE 顯示在地點類型圖示旁,PHOTO 顯示在相片上的徽章,NONE 則顯示在圖釘的主要內容。
--gmp-background
圖釘的背景顏色:藥丸、相框、相片徽章、尖角和地點類型圖釘的邊框。
--gmp-border-radius
PHOTO 圖釘中,藥丸形狀 (地點類型圖示和版位內容,或只有版位內容) 和相框的邊框半徑。預設值:30px (地點類型圖示和版位內容)、12px (僅限版位內容),以及 12px 相框。不適用於沒有插槽內容的地點類型圖釘。
--gmp-glyph-background
地點類型字符後方的背景顏色。預設為地點的 iconBackgroundColor。
--gmp-glyph-color
地點類型字符的顏色。只要顯示字符,就會套用這個屬性,包括 PHOTO 圖釘改用地點類型圖示時。
繼承: addEventListener、removeEventListener
gmp-error
function(event)
引數:
如果圖釘完全無法算繪,就會觸發這個事件,例如網路故障、憑證失敗 (例如 API 金鑰不正確)、無法解析地點 ID,或地點沒有位置。圖釘會隱藏起來。這個事件不會向上傳遞。
gmp-load
function(event)
引數:
載入地點詳細資料並算繪圖釘後,就會觸發這個事件。當 icon 為 PHOTO 時,只有在相片載入或失敗後才會觸發;單純相片失敗不會觸發 gmp-error。從 PlacePinElement.place 讀取載入的地點,以及是否從 PlacePinElement.photoRendered 顯示相片。這個事件不會向上傳遞。

PlacePinElementOptions 介面

介面 google.maps.places.PlacePinElementOptions
由 PlacePinElement 實作

建構 PlacePinElement 的選項。

icon
選填
類型: PlacePinIcon optional
詳情請參閱《PlacePinElement.icon》。
scale
選填
類型: number optional
詳情請參閱《PlacePinElement.scale》。

PlacePinIcon 常數

constants google.maps.places.PlacePinIcon
library "places"

PlacePinElement 的圖示選項。預設值為 TYPE。如果缺少所選圖示所需的資料,圖釘會改用 TYPE。如果缺少 TYPE 所需的資料,系統會改為顯示一般圖示。

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

const {PlacePinIcon} = await google.maps.importLibrary("places");
NONE 不顯示圖示,只顯示插槽內容。
PHOTO 在圓圈中顯示地點的相片。如果地點沒有相片,則會改用 TYPE。
TYPE 顯示地點的類別圖示。