Places Widgets

PlaceAutocompleteElement 类

google.maps.places.PlaceAutocompleteElement 类

PlaceAutocompleteElement 是 HTMLElement 子类,可为 Places 地点自动补全 API 提供界面组件。

PlaceAutocompleteElement 会自动在内部使用 AutocompleteSessionToken,将用户自动补全搜索的查询和选择阶段归入不同的会话。

首次对 PlacePrediction.toPlace 返回的 Place 调用 Place.fetchFields 时,系统会自动添加用于提取 PlacePrediction 的会话令牌。

如需详细了解会话令牌的工作原理,请参阅 https://developers.google.com/maps/documentation/places/web-service/place-session-tokens。

自定义元素:
<gmp-place-autocomplete included-primary-types="type1 type2 type3..." included-region-codes="c1 c2 c3..." name="string" origin="lat,lng" requested-language="string" requested-region="string" unit-system="metric"></gmp-place-autocomplete>

此类扩展了 HTMLElement。

此类实现 PlaceAutocompleteElementOptions。

通过拨打 const {PlaceAutocompleteElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceAutocompleteElement
PlaceAutocompleteElement(options)
参数:
includedPrimaryTypes
类型:Array<string> optional
包含的主要地点类型(例如“restaurant”或“gas_station”)。

只有在地点的主要类型包含在此列表中时,系统才会返回该地点。最多可以指定 5 个值。如果未指定任何类型,系统将返回所有地点类型。
HTML 属性:
  • <gmp-place-autocomplete included-primary-types="type1 type2 type3..."></gmp-place-autocomplete>
includedRegionCodes
类型:Array<string> optional
仅包含指定区域的结果,最多可指定 15 个 CLDR 双字符区域代码。空集不会限制结果。如果同时设置了 locationRestriction 和 includedRegionCodes,则结果将位于交集区域。
HTML 属性:
  • <gmp-place-autocomplete included-region-codes="c1 c2 c3..."></gmp-place-autocomplete>
locationBias
类型:LocationBias optional
在搜索地点时使用的软边界或提示。
locationRestriction
类型:LocationRestriction optional
用于限制搜索结果的边界。
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 属性:
  • <gmp-place-autocomplete name="string"></gmp-place-autocomplete>
origin
计算距离的起点。如果未指定,则不计算距离。如果提供了海拔高度,则不会在计算中使用。
HTML 属性:
  • <gmp-place-autocomplete origin="lat,lng"></gmp-place-autocomplete>
  • <gmp-place-autocomplete origin="lat,lng,altitude"></gmp-place-autocomplete>
placeholder
类型:string
要在输入元素中显示的占位文本。
requestedLanguage
类型:string optional
语言标识符,用于指定返回结果时应使用的语言(如果可能)。所选语言的结果可能会获得更高的排名,但建议并不局限于此语言。请参阅支持的语言列表。
HTML 属性:
  • <gmp-place-autocomplete requested-language="string"></gmp-place-autocomplete>
requestedRegion
类型:string optional
用于结果格式设置和结果过滤的地区代码。它不会将建议限制为此国家/地区。地区代码接受 ccTLD(“顶级域名”)双字符值。多数 ccTLD 代码都与 ISO 3166-1 代码相同,但也有一些需要注意的例外情况。例如,英国的 ccTLD 为“uk”(.co.uk),而其 ISO 3166-1 代码为“gb”(代表“大不列颠及北爱尔兰联合王国”)。
HTML 属性:
  • <gmp-place-autocomplete requested-region="string"></gmp-place-autocomplete>
unitSystem
类型:UnitSystem optional
用于显示距离的单位制。如果未指定,则单位制由 requestedRegion 决定。
HTML 属性:
  • <gmp-place-autocomplete unit-system="metric"></gmp-place-autocomplete>
  • <gmp-place-autocomplete unit-system="imperial"></gmp-place-autocomplete>
value
类型:string
输入元素的值。
prediction-item-icon
此槽仅接受一个 <template> 元素,该元素会呈现为联想查询项旁边显示的图标。
input
自动补全元素的输入元素。
prediction-item
预测结果下拉列表中的一个条目,代表一个预测结果。
prediction-item-icon
预测项列表中显示在每个项目左侧的图标。
prediction-item-main-text
prediction-item 的一部分,它是预测结果的主要文本。对地理位置而言,它会包含地点名称(如“上海”)或街道名称和编号(如“长安大街3号”)。默认情况下,prediction-item-main-text 显示为黑色。如果 prediction-item 中有任何附加文本,该文本将位于 prediction-item-main-text 之外,并且继承 prediction-item 的样式。默认情况下,此类文本会显示为灰色。附加文本通常是地址。
prediction-item-match
返回的联想查询的一部分,其于用户输入相匹配。默认情况下,该匹配文本以粗体突出显示。请注意,匹配的文本可能位于 prediction-item 中的任何位置。它不一定是 prediction-item-main-text 的一部分。
prediction-item-selected
用户通过键盘导航到的条目。注意:所选内容会同时受此部分样式和 prediction-item 部分样式的影响。
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
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。
gmp-error
function(errorEvent)
参数: 
当对后端的请求被拒绝(例如 API 密钥不正确)时,会触发此事件。此事件不会冒泡。
gmp-select
function(placePredictionSelectEvent)
参数: 
当用户选择地点联想查询时,系统会触发此事件。包含可转换为 Place 对象的 PlacePrediction 对象。

PlaceAutocompleteElementOptions 接口

google.maps.places.PlaceAutocompleteElementOptions 接口

用于构建 PlaceAutocompleteElement 的选项。如需了解每个属性的说明,请参阅 PlaceAutocompleteElement 类中的同名属性。

includedPrimaryTypes optional
类型:Array<string> optional
includedRegionCodes optional
类型:Array<string> optional
locationBias optional
类型:LocationBias optional
locationRestriction optional
类型:LocationRestriction optional
name optional
类型:string optional
origin optional
requestedLanguage optional
类型:string optional
requestedRegion optional
类型:string optional
unitSystem optional
类型:UnitSystem optional
value optional
类型:string optional
输入元素的值。

PlacePredictionSelectEvent 类

google.maps.places.PlacePredictionSelectEvent 类

此事件会在用户使用 PlaceAutocompleteElement 选择预测结果项后创建。使用 event.placePrediction 访问所选内容。

通过调用 PlacePrediction.toPlace 将 placePrediction 转换为 Place。

此类扩展了 Event。

通过拨打 const {PlacePredictionSelectEvent} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

placePrediction
通过调用 PlacePrediction.toPlace 将其转换为 Place。

BasicPlaceAutocompleteElement 类

google.maps.places.BasicPlaceAutocompleteElement 类

BasicPlaceAutocompleteElement 是 HTMLElement 子类,可为 Places Autocomplete API 提供界面组件。

自定义元素:
<gmp-basic-place-autocomplete included-primary-types="type1 type2 type3..." included-region-codes="c1 c2 c3..." name="string" origin="lat,lng" requested-language="string" requested-region="string" unit-system="metric"></gmp-basic-place-autocomplete>

此类扩展了 HTMLElement。

此类实现 BasicPlaceAutocompleteElementOptions。

通过拨打 const {BasicPlaceAutocompleteElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

BasicPlaceAutocompleteElement
BasicPlaceAutocompleteElement(options)
includedPrimaryTypes
类型:Array<string> optional
包含的主要地点类型(例如“restaurant”或“gas_station”)。

只有在地点的主要类型包含在此列表中时,系统才会返回该地点。最多可以指定 5 个值。如果未指定任何类型,系统将返回所有地点类型。
HTML 属性:
  • <gmp-basic-place-autocomplete included-primary-types="type1 type2 type3..."></gmp-basic-place-autocomplete>
includedRegionCodes
类型:Array<string> optional
仅包含指定区域的结果,最多可指定 15 个 CLDR 双字符区域代码。空集不会限制结果。如果同时设置了 locationRestriction 和 includedRegionCodes,则结果将位于交集区域。
HTML 属性:
  • <gmp-basic-place-autocomplete included-region-codes="c1 c2 c3..."></gmp-basic-place-autocomplete>
locationBias
类型:LocationBias optional
在搜索地点时使用的软边界或提示。
locationRestriction
类型:LocationRestriction optional
用于限制搜索结果的边界。
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 属性:
  • <gmp-basic-place-autocomplete name="string"></gmp-basic-place-autocomplete>
origin
计算距离的起点。如果未指定,则不计算距离。如果提供了海拔高度,则不会在计算中使用。
HTML 属性:
  • <gmp-basic-place-autocomplete origin="lat,lng"></gmp-basic-place-autocomplete>
  • <gmp-basic-place-autocomplete origin="lat,lng,altitude"></gmp-basic-place-autocomplete>
requestedLanguage
类型:string optional
语言标识符,用于指定返回结果时应使用的语言(如果可能)。所选语言的结果可能会获得更高的排名,但建议并不局限于此语言。请参阅支持的语言列表。
HTML 属性:
  • <gmp-basic-place-autocomplete requested-language="string"></gmp-basic-place-autocomplete>
requestedRegion
类型:string optional
用于结果格式设置和结果过滤的地区代码。它不会将建议限制为此国家/地区。地区代码接受 ccTLD(“顶级域名”)双字符值。多数 ccTLD 代码都与 ISO 3166-1 代码相同,但也有一些需要注意的例外情况。例如,英国的 ccTLD 为“uk”(.co.uk),而其 ISO 3166-1 代码为“gb”(代表“大不列颠及北爱尔兰联合王国”)。
HTML 属性:
  • <gmp-basic-place-autocomplete requested-region="string"></gmp-basic-place-autocomplete>
unitSystem
类型:UnitSystem optional
用于显示距离的单位制。如果未指定,则单位制由 requestedRegion 决定。
HTML 属性:
  • <gmp-basic-place-autocomplete unit-system="metric"></gmp-basic-place-autocomplete>
  • <gmp-basic-place-autocomplete unit-system="imperial"></gmp-basic-place-autocomplete>
prediction-item-icon
此槽仅接受一个 <template> 元素,该元素会呈现为联想查询项旁边显示的图标。
input
自动补全元素的输入元素。
prediction-item
预测结果下拉列表中的一个条目,代表一个预测结果。
prediction-item-icon
预测项列表中显示在每个项目左侧的图标。
prediction-item-main-text
prediction-item 的一部分,它是预测结果的主要文本。对地理位置而言,它会包含地点名称(如“上海”)或街道名称和编号(如“长安大街3号”)。默认情况下,prediction-item-main-text 显示为黑色。如果 prediction-item 中有任何附加文本,该文本将位于 prediction-item-main-text 之外,并且继承 prediction-item 的样式。默认情况下,此类文本会显示为灰色。附加文本通常是地址。
prediction-item-match
返回的联想查询的一部分,其于用户输入相匹配。默认情况下,该匹配文本以粗体突出显示。请注意,匹配的文本可能位于 prediction-item 中的任何位置。它不一定是 prediction-item-main-text 的一部分。
prediction-item-selected
用户通过键盘导航到的条目。注意:所选内容会同时受此部分样式和 prediction-item 部分样式的影响。
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
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。
gmp-error
function(errorEvent)
参数: 
当对后端的请求被拒绝(例如 API 密钥不正确)时,会触发此事件。此事件不会冒泡。
gmp-select
function(placeSelectEvent)
参数: 
当用户选择地点联想查询时,系统会触发此事件。包含 Place 对象。

BasicPlaceAutocompleteElementOptions 接口

google.maps.places.BasicPlaceAutocompleteElementOptions 接口

用于构建 BasicPlaceAutocompleteElement 的选项。

includedPrimaryTypes optional
类型:Array<string> optional
includedRegionCodes optional
类型:Array<string> optional
locationBias optional
类型:LocationBias optional
locationRestriction optional
类型:LocationRestriction optional
name optional
类型:string optional
origin optional
requestedLanguage optional
类型:string optional
requestedRegion optional
类型:string optional
unitSystem optional
类型:UnitSystem optional

PlaceDetailsElement 类

google.maps.places.PlaceDetailsElement 类

以完整布局显示地点的详细信息。附加 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></gmp-place-details>

此类扩展了 HTMLElement。

此类实现 PlaceDetailsElementOptions。

通过拨打 const {PlaceDetailsElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceDetailsElement
PlaceDetailsElement([options])
参数:
place
类型:Place optional
只读。Place 对象,其中包含当前呈现的地点的 ID、位置和视口。
--gmp-button-border-color
“在地图中打开”按钮的边框颜色。
--gmp-button-border-radius
“在地图中打开”按钮的边框半径。
--gmp-button-border-width
“在地图中打开”按钮的边框宽度。
--gmp-collage-border-radius-outer
媒体拼贴外角的边框半径。
--gmp-dialog-border-radius
Google 地图披露对话框的边框半径。
--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
与次要容器颜色形成对比的文字和图标颜色。用于“在 Google 地图中打开”按钮上的文字和图标。
--gmp-mat-color-on-surface
与任何 surface 颜色搭配使用的文字和图标颜色。用于常规文本。
--gmp-mat-color-on-surface-variant
在任何 Surface 颜色上,文本和图标的强调色都较低。用于不太强调的文本。
--gmp-mat-color-outline-decorative
非互动元素的轮廓颜色。用于元素的边框。
--gmp-mat-color-positive
具有积极情绪的界面元素的颜色。用于“正在营业”状态中的“营业中”文本。
--gmp-mat-color-positive-container
用于传达积极情绪的界面元素的容器颜色。用于电动汽车充电桩可用性标志(如有)。
--gmp-mat-color-primary
互动文本和图标与表面颜色的对比色。用于评价数量、Google 地图披露信息对话框中的链接、网站链接、“概览”标签页中的图标,以及标签页栏标题(悬停/焦点/文字颜色)。
--gmp-mat-color-secondary-container
与表面色相比,填充颜色不太显眼,适用于色调按钮等隐性组件。用于“在地图中打开”按钮的背景。
--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
缩放元素中的所有文本和图标,这些文本和图标在内部以 em 为单位进行定义。默认为 16px。
addEventListener
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。
gmp-error
function(event)
参数: 
当对后端的请求被拒绝(例如 API 密钥不正确)时,会触发此事件。此事件不会冒泡。
gmp-load
function(event)
参数: 
当元素加载并呈现其内容时,会触发此事件。此事件不会冒泡。

PlaceDetailsElementOptions 接口

google.maps.places.PlaceDetailsElementOptions 接口

“PlaceDetailsElement”的选项。

PlaceDetailsCompactElement 类

google.maps.places.PlaceDetailsCompactElement 类

以紧凑布局显示地点的详细信息。附加 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 orientation="vertical" truncation-preferred></gmp-place-details-compact>

此类扩展了 HTMLElement。

此类实现 PlaceDetailsCompactElementOptions。

通过拨打 const {PlaceDetailsCompactElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceDetailsCompactElement
PlaceDetailsCompactElement([options])
参数:
orientation
类型:PlaceDetailsOrientation optional
默认值:PlaceDetailsOrientation.VERTICAL
元素的方向变体(垂直或水平)。
HTML 属性:
  • <gmp-place-details-compact orientation="vertical"></gmp-place-details-compact>
  • <gmp-place-details-compact orientation="horizontal"></gmp-place-details-compact>
place
类型:Place optional
只读。Place 对象,其中包含当前呈现的地点的 ID、位置和视口。
truncationPreferred
类型:boolean
默认值:false
如果为 true,则会截断地点名称和地址,使其显示在一行中,而不是换行。
HTML 属性:
  • <gmp-place-details-compact truncation-preferred></gmp-place-details-compact>
--gmp-button-border-color
“在地图中打开”按钮的边框颜色。
--gmp-button-border-radius
“在地图中打开”按钮的边框半径。
--gmp-button-border-width
“在地图中打开”按钮的边框宽度。
--gmp-dialog-border-radius
Google 地图披露对话框的边框半径。
--gmp-mat-color-info
具有信息性情感的界面元素的颜色。用于轮椅图标。
--gmp-mat-color-negative
带有负面情绪的界面元素的颜色。用于“正在营业”状态中的“已打烊”文本。
--gmp-mat-color-neutral-container
中性填充界面元素的容器颜色。用于图片占位符。
--gmp-mat-color-on-secondary-container
与次要容器颜色形成对比的文字和图标颜色。用于“在 Google 地图中打开”按钮上的文字和图标。
--gmp-mat-color-on-surface
与任何 surface 颜色搭配使用的文字和图标颜色。用于常规文本。
--gmp-mat-color-on-surface-variant
在任何 Surface 颜色上,文本和图标的强调色都较低。用于不太强调的文本。
--gmp-mat-color-outline-decorative
非互动元素的轮廓颜色。用于元素的边框。
--gmp-mat-color-positive
具有积极情绪的界面元素的颜色。用于“正在营业”状态中的“营业中”文本。
--gmp-mat-color-primary
互动文本和图标与表面颜色的对比色。用于评价数量,以及 Google 地图披露信息对话框中的链接。
--gmp-mat-color-secondary-container
与表面色相比,填充颜色不太显眼,适用于色调按钮等隐性组件。用于“在地图中打开”按钮的背景。
--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。
addEventListener
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。
gmp-error
function(event)
参数: 
当对后端的请求被拒绝(例如 API 密钥不正确)时,会触发此事件。此事件不会冒泡。
gmp-load
function(event)
参数: 
当元素加载并呈现其内容时,会触发此事件。此事件不会冒泡。

PlaceDetailsCompactElementOptions 接口

google.maps.places.PlaceDetailsCompactElementOptions 接口

“PlaceDetailsCompactElement”的选项。

orientation optional
类型:PlaceDetailsOrientation optional
truncationPreferred optional
类型:boolean optional

PlaceDetailsOrientation 常量

google.maps.places.PlaceDetailsOrientation 常量

PlaceDetailsCompactElement 的方向变体。

通过拨打 const {PlaceDetailsOrientation} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

HORIZONTAL 横向。
VERTICAL 垂直方向。

PlaceDetailsPlaceRequestElement 类

google.maps.places.PlaceDetailsPlaceRequestElement 类

配置 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="some-place-id"></gmp-place-details-place-request>

此类扩展了 HTMLElement。

此类实现 PlaceDetailsPlaceRequestElementOptions。

通过拨打 const {PlaceDetailsPlaceRequestElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceDetailsPlaceRequestElement
PlaceDetailsPlaceRequestElement([options])
参数:
place
类型:Place optional
默认值:null
要在“地点详情(精简版)”元素中呈现其详情的地点对象、ID 或资源名称。此属性会作为资源名称反映到该属性。
HTML 属性:
  • <gmp-place-details-place-request place="some-place-id"></gmp-place-details-place-request>
addEventListener
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。

PlaceDetailsPlaceRequestElementOptions 接口

google.maps.places.PlaceDetailsPlaceRequestElementOptions 接口

“PlaceDetailsPlaceRequestElement”的选项。

place optional
类型:Place|string optional

PlaceDetailsLocationRequestElement 类

google.maps.places.PlaceDetailsLocationRequestElement 类

配置 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>

此类扩展了 HTMLElement。

此类实现 PlaceDetailsLocationRequestElementOptions。

通过拨打 const {PlaceDetailsLocationRequestElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceDetailsLocationRequestElement
PlaceDetailsLocationRequestElement([options])
参数:
location
默认值:null
要在“地点详情”元素中呈现其详细信息的地点。归一化为 LatLngAltitude。
HTML 属性:
  • <gmp-place-details-location-request location="lat,lng"></gmp-place-details-location-request>
addEventListener
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。

PlaceDetailsLocationRequestElementOptions 接口

google.maps.places.PlaceDetailsLocationRequestElementOptions 接口

“PlaceDetailsLocationRequestElement”的选项。

location optional
要呈现地点的地理位置。

PlaceSearchElement 类

google.maps.places.PlaceSearchElement 类

以列表形式显示地点搜索结果。附加 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>

如需使用地点搜索元素,请在 Google Cloud 控制台中为您的项目启用 Places UI Kit API。

自定义元素:
<gmp-place-search attribution-position="top" orientation="vertical" selectable truncation-preferred></gmp-place-search>

此类扩展了 HTMLElement。

此类实现 PlaceSearchElementOptions。

通过拨打 const {PlaceSearchElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceSearchElement
PlaceSearchElement([options])
参数:
attributionPosition
默认值:PlaceSearchAttributionPosition.TOP
提供方徽标和依法披露按钮的位置。
HTML 属性:
  • <gmp-place-search attribution-position="top"></gmp-place-search>
  • <gmp-place-search attribution-position="bottom"></gmp-place-search>
orientation
类型:PlaceSearchOrientation optional
默认值:PlaceSearchOrientation.VERTICAL
元素的方向变体(垂直或水平)。
HTML 属性:
  • <gmp-place-search orientation="vertical"></gmp-place-search>
  • <gmp-place-search orientation="horizontal"></gmp-place-search>
places
类型:Array<Place>
只读。Place 对象数组,其中包含当前呈现的地点的 ID、位置和视口。
selectable
类型:boolean optional
默认值:false
列表项是否可供选择。如果为 true,列表项将是按钮,点击时会分派 gmp-select 事件。此外,还支持无障碍键盘导航和选择。
HTML 属性:
  • <gmp-place-search selectable></gmp-place-search>
truncationPreferred
类型:boolean optional
默认值:false
如果为 true,则会截断某些内容行,使其在一行中显示,而不是换行。
HTML 属性:
  • <gmp-place-search truncation-preferred></gmp-place-search>
--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
具有信息性情感的界面元素的颜色。用于表示无障碍入口的图标。
--gmp-mat-color-negative
带有负面情绪的界面元素的颜色。用于表示地点营业时间的“已停业”标签。
--gmp-mat-color-neutral-container
中性填充界面元素的容器颜色。用于评价日期标记和加载占位符形状。
--gmp-mat-color-on-neutral-container
中性容器上的文字和图标的颜色。用于评价日期文本和加载错误文本。
--gmp-mat-color-on-secondary-container
文本和图标在次要容器颜色上的颜色。用于按钮文本和图标。
--gmp-mat-color-on-surface
与 surface 颜色形成对比的文字和图标颜色。用于标题和对话框内容。
--gmp-mat-color-on-surface-variant
在 Surface 颜色上显示的文本和图标的低强调色。用于地点信息。
--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-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
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。
gmp-error
function(event)
参数: 
当对后端的请求被拒绝(例如 API 密钥不正确)时,会触发此事件。此事件不会冒泡。
gmp-load
function(event)
参数: 
当元素加载并呈现其内容时,会触发此事件。此事件不会冒泡。
gmp-select
function(event)
参数: 
当用户从列表中选择地点时,系统会触发此事件。包含一个 Place 对象,其中包含所选地点的 ID、位置和视口。

PlaceSearchElementOptions 接口

google.maps.places.PlaceSearchElementOptions 接口

“PlaceSearchElement”的选项。

attributionPosition optional
orientation optional
类型:PlaceSearchOrientation optional
selectable optional
类型:boolean optional
truncationPreferred optional
类型:boolean optional

PlaceSearchAttributionPosition 常量

google.maps.places.PlaceSearchAttributionPosition 常量

PlaceSearchElement 的归因位置。

通过拨打 const {PlaceSearchAttributionPosition} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

BOTTOM PlaceSearchElement 底部的提供方信息
TOP PlaceSearchElement 顶部的提供方信息

PlaceSearchOrientation 常量

google.maps.places.PlaceSearchOrientation 常量

PlaceSearchElement 的方向变体。

通过拨打 const {PlaceSearchOrientation} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

HORIZONTAL 横向。
VERTICAL 垂直方向。

PlaceSelectEvent 类

google.maps.places.PlaceSelectEvent 类

此事件会在从地点列表中选择某个地点时触发。使用 event.place 访问所选内容。

此类扩展了 Event。

通过拨打 const {PlaceSelectEvent} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

place
类型:Place
所选地点。

PlaceNearbySearchRequestElement 类

google.maps.places.PlaceNearbySearchRequestElement 类

配置 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="preference"></gmp-place-nearby-search-request>

此类扩展了 HTMLElement。

此类实现 PlaceNearbySearchRequestElementOptions。

通过拨打 const {PlaceNearbySearchRequestElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceNearbySearchRequestElement
PlaceNearbySearchRequestElement([options])
参数:
excludedPrimaryTypes
类型:Array<string> optional
默认值:null
已排除的主要地点类型。
HTML 属性:
  • <gmp-place-nearby-search-request excluded-primary-types="excluded-primary-type1 excluded-primary-type2..."></gmp-place-nearby-search-request>
excludedTypes
类型:Array<string> optional
默认值:null
排除的地点类型。
HTML 属性:
  • <gmp-place-nearby-search-request excluded-types="excluded-type1 excluded-type2..."></gmp-place-nearby-search-request>
includedPrimaryTypes
类型:Array<string> optional
默认值:null
包含的主要地点类型。
HTML 属性:
  • <gmp-place-nearby-search-request included-primary-types="included-primary-type1 included-primary-type2..."></gmp-place-nearby-search-request>
includedTypes
类型:Array<string> optional
默认值:null
包含的地点类型。
HTML 属性:
  • <gmp-place-nearby-search-request included-types="included-type1 included-type2..."></gmp-place-nearby-search-request>
locationRestriction
类型:Circle|CircleLiteral optional
默认值:null
要搜索的区域。归一化为 Circle。
HTML 属性:
  • <gmp-place-nearby-search-request location-restriction="radius@lat,lng"></gmp-place-nearby-search-request>
maxResultCount
类型:number optional
默认值:null
返回的结果数上限。
HTML 属性:
  • <gmp-place-nearby-search-request max-result-count="number"></gmp-place-nearby-search-request>
rankPreference
类型:SearchNearbyRankPreference optional
默认值:null
回答中结果的排序方式。
HTML 属性:
  • <gmp-place-nearby-search-request rank-preference="preference"></gmp-place-nearby-search-request>
addEventListener
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。

PlaceNearbySearchRequestElementOptions 接口

google.maps.places.PlaceNearbySearchRequestElementOptions 接口

“PlaceNearbySearchRequestElement”的选项。

excludedPrimaryTypes optional
类型:Array<string> optional
已排除的主要地点类型。如需了解详情,请参阅 PlaceNearbySearchRequestElement.excludedPrimaryTypes 和 SearchNearbyRequest.excludedPrimaryTypes。
excludedTypes optional
类型:Array<string> optional
排除的地点类型。如需了解详情,请参阅 PlaceNearbySearchRequestElement.excludedTypes 和 SearchNearbyRequest.excludedTypes。
includedPrimaryTypes optional
类型:Array<string> optional
包含的主要地点类型。如需了解详情,请参阅 PlaceNearbySearchRequestElement.includedPrimaryTypes 和 SearchNearbyRequest.includedPrimaryTypes。
includedTypes optional
类型:Array<string> optional
包含的地点类型。如需了解详情,请参阅 PlaceNearbySearchRequestElement.includedTypes 和 SearchNearbyRequest.includedTypes。
locationRestriction optional
类型:Circle|CircleLiteral optional
要搜索的区域。如需了解详情,请参阅 PlaceNearbySearchRequestElement.locationRestriction 和 SearchNearbyRequest.locationRestriction。
maxResultCount optional
类型:number optional
页面中结果的数量上限。如需了解详情,请参阅 PlaceNearbySearchRequestElement.maxResultCount 和 SearchNearbyRequest.maxResultCount。
rankPreference optional
类型:SearchNearbyRankPreference optional
结果在响应中的排名方式。如需了解详情,请参阅 PlaceNearbySearchRequestElement.rankPreference 和 SearchNearbyRankPreference。

PlaceTextSearchRequestElement 类

google.maps.places.PlaceTextSearchRequestElement 类

配置 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="rate" included-type="type" is-open-now="true" location-bias="lat,lng" location-restriction="swlat,swlng|nelat,nelng" max-result-count="number" min-rating="number" price-levels="price-level1 price-level2..." rank-preference="preference" text-query="string" use-strict-type-filtering></gmp-place-text-search-request>

此类扩展了 HTMLElement。

此类实现 PlaceTextSearchRequestElementOptions。

通过拨打 const {PlaceTextSearchRequestElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceTextSearchRequestElement
PlaceTextSearchRequestElement([options])
参数:
evConnectorTypes
类型:Array<EVConnectorType> optional
默认值:null
首选电动汽车连接器类型列表。
HTML 属性:
  • <gmp-place-text-search-request ev-connector-types="ev-connector-type1 ev-connector-type2..."></gmp-place-text-search-request>
evMinimumChargingRateKw
类型:number optional
默认值:null
最低充电速率要求(以千瓦为单位)。
HTML 属性:
  • <gmp-place-text-search-request ev-minimum-charging-rate-kw="rate"></gmp-place-text-search-request>
includedType
类型:string optional
默认值:null
请求的地点类型。
HTML 属性:
  • <gmp-place-text-search-request included-type="type"></gmp-place-text-search-request>
isOpenNow
类型:boolean optional
默认值:null
用于将搜索范围限制为当前营业的地点。
HTML 属性:
  • <gmp-place-text-search-request is-open-now="true"></gmp-place-text-search-request>
locationBias
类型:LocationBias optional
默认值:null
搜索的位置偏向。归一化为 LatLngAltitude | LatLngBounds | Circle | string。
HTML 属性:
  • <gmp-place-text-search-request location-bias="lat,lng"></gmp-place-text-search-request>
  • <gmp-place-text-search-request location-bias="lat,lng[,altitude]"></gmp-place-text-search-request>
  • <gmp-place-text-search-request location-bias="swlat,swlng|nelat,nelng"></gmp-place-text-search-request>
  • <gmp-place-text-search-request location-bias="radius@lat,lng"></gmp-place-text-search-request>
  • <gmp-place-text-search-request location-bias="IP_BIAS"></gmp-place-text-search-request>
locationRestriction
默认值:null
搜索的位置限制。归一化为 LatLngBounds。
HTML 属性:
  • <gmp-place-text-search-request location-restriction="swlat,swlng|nelat,nelng"></gmp-place-text-search-request>
maxResultCount
类型:number optional
默认值:null
返回的结果数上限。
HTML 属性:
  • <gmp-place-text-search-request max-result-count="number"></gmp-place-text-search-request>
minRating
类型:number optional
默认值:null
滤除平均房客评分严格低于此限制的结果。
HTML 属性:
  • <gmp-place-text-search-request min-rating="number"></gmp-place-text-search-request>
priceLevels
类型:Array<PriceLevel> optional
默认值:null
用于将搜索范围限制为标记为特定价格水平的地点。
HTML 属性:
  • <gmp-place-text-search-request price-levels="price-level1 price-level2..."></gmp-place-text-search-request>
rankPreference
类型:SearchByTextRankPreference optional
默认值:null
回答中结果的排序方式。
HTML 属性:
  • <gmp-place-text-search-request rank-preference="preference"></gmp-place-text-search-request>
textQuery
类型:string optional
默认值:null
文本搜索的文本查询。
HTML 属性:
  • <gmp-place-text-search-request text-query="string"></gmp-place-text-search-request>
useStrictTypeFiltering
类型:boolean optional
默认值:null
用于为“includedType”设置严格的类型过滤。
HTML 属性:
  • <gmp-place-text-search-request use-strict-type-filtering></gmp-place-text-search-request>
addEventListener
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。

PlaceTextSearchRequestElementOptions 接口

google.maps.places.PlaceTextSearchRequestElementOptions 接口

“PlaceTextSearchRequestElement”的选项。

evConnectorTypes optional
类型:Array<EVConnectorType> optional
首选电动汽车连接器类型列表。如需了解详情,请参阅 SearchByTextRequest.evSearchOptions 和 PlaceTextSearchRequestElement.evConnectorTypes。
evMinimumChargingRateKw optional
类型:number optional
最低充电速率(以千瓦为单位)。如需了解详情,请参阅 SearchByTextRequest.evSearchOptions 和 PlaceTextSearchRequestElement.evMinimumChargingRateKw。
includedType optional
类型:string optional
请求的地点类型。如需了解详情,请参阅 SearchByTextRequest.includedType 和 PlaceTextSearchRequestElement.includedType。
isOpenNow optional
类型:boolean optional
用于将搜索范围限制为当前正在营业的地点。如需了解详情,请参阅 SearchByTextRequest.isOpenNow 和 PlaceTextSearchRequestElement.isOpenNow。
locationBias optional
类型:LocationBias optional
搜索的位置偏向。如需了解详情,请参阅 SearchByTextRequest.locationBias 和 PlaceTextSearchRequestElement.locationBias。
locationRestriction optional
搜索的位置限制。如需了解详情,请参阅 SearchByTextRequest.locationRestriction 和 PlaceTextSearchRequestElement.locationRestriction。
maxResultCount optional
类型:number optional
页面中结果的数量上限。如需了解详情,请参阅 SearchByTextRequest.maxResultCount 和 PlaceTextSearchRequestElement.maxResultCount。
minRating optional
类型:number optional
滤除平均房客评分严格低于此限制的结果。如需了解详情,请参阅 SearchByTextRequest.minRating 和 PlaceTextSearchRequestElement.minRating。
priceLevels optional
类型:Array<PriceLevel> optional
用于将搜索范围限制为标记为特定价格水平的地点。如需了解详情,请参阅 SearchByTextRequest.priceLevels 和 PlaceTextSearchRequestElement.priceLevels。
rankPreference optional
类型:SearchByTextRankPreference optional
结果在响应中的排名方式。如需了解详情,请参阅 SearchByTextRequest.rankPreference 和 PlaceTextSearchRequestElement.rankPreference。
textQuery optional
类型:string optional
文本搜索的文本查询。如需了解详情,请参阅 SearchByTextRequest.textQuery 和 PlaceTextSearchRequestElement.textQuery。
useStrictTypeFiltering optional
类型:boolean optional

Autocomplete 类

google.maps.places.Autocomplete 类

一个根据用户输入的文本提供地点联想查询的小部件。它会附加到 text 类型的输入元素,并监听该字段中的文本输入。预测结果列表会以一个下拉列表的形式呈现,并随着用户输入文本而更新。

此类扩展了 MVCObject。

通过拨打 const {Autocomplete} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

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 要包含的预测类型。
返回值:无
设置要返回的联想查询类型。如需了解支持的类型,请参阅 开发者指南。如果未指定任何类型,系统将返回所有类型。
继承的方法: addListener、bindTo、get、notify、set、setValues、unbind、unbindAll
place_changed
function()
参数:None
当用户所选地点的 PlaceResult 可用时,系统会触发此事件。
如果用户输入了控件未建议的地点名称并按 Enter 键,或者如果地点详情请求失败,则 PlaceResult 会在 name 属性中包含用户输入,而不会定义其他属性。

AutocompleteOptions 接口

google.maps.places.AutocompleteOptions 接口

可在 Autocomplete 对象上设置的选项。

bounds optional
要在其中搜索地点的区域。
componentRestrictions optional
类型:ComponentRestrictions optional
组件限制。组件限制用于将预测结果限制在父组件内。例如,国家/地区。
fields optional
类型:Array<string> optional
成功检索到详情后,详情响应中要包含的地点字段,这些字段将计费。如果传入的是 ['ALL'],系统会返回所有可用字段并据此计费(不建议用于生产环境中的部署)。如需查看字段列表,请参阅 PlaceResult。可以使用点路径(例如 "geometry.location")指定嵌套字段。默认值为 ['ALL']。
placeIdOnly optional
类型:boolean optional
是否仅检索地点 ID。触发 place_changed 事件时提供的 PlaceResult 将仅包含 place_id、types 和 name 字段,以及自动补全服务返回的 place_id、types 和 description。默认情况下,该环境处于停用状态。
strictBounds optional
类型:boolean optional
一个布尔值,表示自动补全 widget 应仅返回那些在发送查询时位于自动补全 widget 边界内的地点。将 strictBounds 设置为 false(默认值)会使结果偏向于(但不限于)边界内包含的地点。
types optional
类型:Array<string> optional
要返回的联想查询类型。如需了解支持的类型,请参阅 开发者指南。如果未指定任何类型,系统将返回所有类型。

google.maps.places.SearchBox 类

一种微件,可根据用户的文本输入提供联想查询。它会附加到 text 类型的输入元素,并监听该字段中的文本输入。预测结果列表会以一个下拉列表的形式呈现,并随着用户输入文本而更新。

此类扩展了 MVCObject。

通过拨打 const {SearchBox} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

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()
参数:None
此事件在用户选择查询时触发,应使用 getPlaces 获取新地点。

SearchBoxOptions 接口

google.maps.places.SearchBoxOptions 接口

可在 SearchBox 对象上设置的选项。

bounds optional
查询联想结果偏向的区域。联想查询偏向于(但不限于)针对这些边界的查询。

PlaceContextualElement 类

google.maps.places.PlaceContextualElement 类

一个使用上下文 token 来显示 Grounding with Google Maps 回答的贴合情境的视图的微件。

自定义元素:
<gmp-place-contextual context-token="string"></gmp-place-contextual>

此类扩展了 HTMLElement。

此类实现 PlaceContextualElementOptions。

通过拨打 const {PlaceContextualElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceContextualElement
PlaceContextualElement([options])
参数:
contextToken
类型:string optional
上下文令牌。
HTML 属性:
  • <gmp-place-contextual context-token="string"></gmp-place-contextual>
addEventListener
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。

PlaceContextualElementOptions 接口

google.maps.places.PlaceContextualElementOptions 接口

“PlaceContextualElement”的选项。

contextToken optional
类型:string optional
Grounding with Google Maps 回答提供的上下文 token。

PlaceContextualListConfigElement 类

google.maps.places.PlaceContextualListConfigElement 类

一个 HTML 元素,用于配置地点情境元素的列表视图选项。

自定义元素:
<gmp-place-contextual-list-config layout="compact" map-hidden></gmp-place-contextual-list-config>

此类扩展了 HTMLElement。

此类实现 PlaceContextualListConfigElementOptions。

通过拨打 const {PlaceContextualListConfigElement} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

PlaceContextualListConfigElement
PlaceContextualListConfigElement([options])
参数:
layout
类型:PlaceContextualListLayout optional
布局。
HTML 属性:
  • <gmp-place-contextual-list-config layout="compact"></gmp-place-contextual-list-config>
  • <gmp-place-contextual-list-config layout="vertical"></gmp-place-contextual-list-config>
mapHidden
类型:boolean optional
地图是否处于隐藏状态。
HTML 属性:
  • <gmp-place-contextual-list-config map-hidden></gmp-place-contextual-list-config>
addEventListener
addEventListener(type, listener[, options])
参数:
  • type:string一个区分大小写的字符串,表示要监听的事件类型。
  • listener:EventListener|EventListenerObject 接收通知的对象。这必须是函数或具有 handleEvent 方法的对象
  • options:boolean|AddEventListenerOptions optional请参阅选项。自定义事件仅支持 capture 和 passive。
返回值:void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener。
removeEventListener
removeEventListener(type, listener[, options])
参数:
返回值:void
从目标中移除之前使用 addEventListener 注册的事件监听器。请参阅 removeEventListener。

PlaceContextualListConfigElementOptions 接口

google.maps.places.PlaceContextualListConfigElementOptions 接口

PlaceContextualListConfigElement 的选项。

layout optional
类型:PlaceContextualListLayout optional
布局。
mapHidden optional
类型:boolean optional
默认值:false
如果应隐藏地图,则为 true。

PlaceContextualListLayout 常量

google.maps.places.PlaceContextualListLayout 常量

地点情境元素支持的列表视图布局列表。

通过拨打 const {PlaceContextualListLayout} = await google.maps.importLibrary("places") 访问。
请参阅 Maps JavaScript API 中的库。

COMPACT 紧凑列表布局:列表项在单行中呈现为链接,溢出项则显示在下拉列表中。
VERTICAL 垂直列表布局:列表项在垂直列表中呈现为卡片。