Places Widgets

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 双字符地区代码。空集不会限制结果。如果同时设置了 locationRestrictionincludedRegionCodes,结果将位于交集区域。
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
此 slot 仅接受一个 <template> 元素,用于渲染显示在预测项旁边的图标。
prediction-item
预测下拉菜单中的项,表示单个预测结果。
prediction-item-icon
预测项列表中显示在每个项目左侧的图标。
prediction-item-main-text
预测项的一部分,是预测结果的主要文本。对地理位置而言,它会包含地点名称(如“上海”)或街道名称和编号(如“长安大街3号”)。默认情况下,prediction-item-main-text 显示为黑色。如果预测项中有任何附加文本,该文本将位于 prediction-item-main-text 之外,并且继承 prediction-item 的样式。默认情况下,此类文本会显示为灰色。附加文本通常是地址。
prediction-item-match
返回的联想查询的一部分,其于用户输入相匹配。默认情况下,该匹配文本以粗体突出显示。请注意,匹配的文本可能位于 prediction-item 中的任何位置。它不一定是 prediction-item-main-text 的一部分。
prediction-item-selected
用户通过键盘导航到的条目。注意:所选条目将同时受到此部分样式和预测条目部分样式的影响。
prediction-list
视觉元素,其包含由商家信息自动填充服务所返回的联想查询列表。此列表通过下拉列表的形式显示在 PlaceAutocompleteElement 下方。
background-color
替换元素的背景颜色。
border
替换元素的边框。
border-radius
替换元素的边框半径。
color-scheme
指示此元素可以采用哪种配色方案进行渲染。如需了解详情,请参阅 color-scheme 文档。默认值为 color-scheme: light dark
addEventListener
addEventListener(type, listener[, options])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  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

PlaceAutocompleteElement

google.maps.places.PlaceAutocompleteElement

PlaceAutocompleteElement 是一个 HTMLElement 子类,可为 Places Autocomplete 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 双字符地区代码。空集不会限制结果。如果同时设置了 locationRestrictionincludedRegionCodes,结果将位于交集区域。
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>
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>
prediction-item
预测下拉菜单中的项,表示单个预测结果。
prediction-item-icon
预测项列表中显示在每个项目左侧的图标。
prediction-item-main-text
预测项的一部分,是预测结果的主要文本。对地理位置而言,它会包含地点名称(如“上海”)或街道名称和编号(如“长安大街3号”)。默认情况下,prediction-item-main-text 显示为黑色。如果预测项中有任何附加文本,该文本将位于 prediction-item-main-text 之外,并且继承 prediction-item 的样式。默认情况下,此类文本会显示为灰色。附加文本通常是地址。
prediction-item-match
返回的联想查询的一部分,其于用户输入相匹配。默认情况下,该匹配文本以粗体突出显示。请注意,匹配的文本可能位于 prediction-item 中的任何位置。它不一定是 prediction-item-main-text 的一部分。
prediction-item-selected
用户通过键盘导航到的条目。注意:所选条目将同时受到此部分样式和预测条目部分样式的影响。
prediction-list
视觉元素,其包含由商家信息自动填充服务所返回的联想查询列表。此列表通过下拉列表的形式显示在 PlaceAutocompleteElement 下方。
background-color
替换元素的背景颜色。
border
替换元素的边框。
border-radius
替换元素的边框半径。
color-scheme
指示此元素可以采用哪种配色方案进行渲染。如需了解详情,请参阅 color-scheme 文档。默认值为 color-scheme: light dark
addEventListener
addEventListener(type, listener[, options])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  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

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
通过调用 PlacePrediction.toPlace 将其转换为 Place

PlaceAutocompleteRequestErrorEvent

google.maps.places.PlaceAutocompleteRequestErrorEvent

当网络请求出现问题时,PlaceAutocompleteElement 会发出此事件。

此类扩展了 Event

通过调用 const {PlaceAutocompleteRequestErrorEvent} = await google.maps.importLibrary("places") 进行访问。
请参阅 Maps JavaScript API 中的库

PlaceContextualElement

google.maps.places.PlaceContextualElement

一种使用上下文令牌来显示“依托 Google 地图进行接地”响应的上下文视图的 widget。

自定义元素:
<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])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener
removeEventListener
removeEventListener(type, listener[, options])
参数: 
返回值:  void
从目标中移除之前通过 addEventListener 注册的事件监听器。请参阅 removeEventListener

PlaceContextualElementOptions 接口

google.maps.places.PlaceContextualElementOptions 接口

PlaceContextualElement 的选项。

contextToken optional
类型:  string optional
“依托 Google 地图进行接地”响应提供的上下文令牌。

PlaceContextualListConfigElement

google.maps.places.PlaceContextualListConfigElement

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

自定义元素:
<gmp-place-contextual-list-config layout="compact" map-hidden map-mode="none"></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>
mapMode
类型:  PlaceContextualListMapMode optional
在地点情境元素中用于地点列表的地图模式。
HTML 属性
  • <gmp-place-contextual-list-config map-mode="none"></gmp-place-contextual-list-config>
  • <gmp-place-contextual-list-config map-mode="roadmap"></gmp-place-contextual-list-config>
  • <gmp-place-contextual-list-config map-mode="hybrid"></gmp-place-contextual-list-config>
addEventListener
addEventListener(type, listener[, options])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  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。
mapMode optional
类型:  PlaceContextualListMapMode optional
在地点情境元素中用于地点列表的地图模式。

PlaceContextualListLayout 常量

google.maps.places.PlaceContextualListLayout 常量

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

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

COMPACT 紧凑型列表布局:列表项以链接的形式呈现在一行中,溢出部分显示在下拉列表中。
VERTICAL 垂直列表布局:列表项以卡片形式在垂直列表中呈现。

PlaceContextualListMapMode 常量

google.maps.places.PlaceContextualListMapMode 常量

在地点情境元素中用于地点列表的地图模式。

通过调用 const {PlaceContextualListMapMode} = await google.maps.importLibrary("places") 进行访问。
请参阅 Maps JavaScript API 中的库

HYBRID 卫星图像或仿真 3D 图像上主要街道的透明图层。
NONE 无地图。
ROADMAP 普通的 2D 街道地图。

PlaceDetailsElement

google.maps.places.PlaceDetailsElement

以完整布局显示某个地点的详细信息。附加 PlaceDetailsPlaceRequestElementPlaceDetailsLocationRequestElement 以指定要呈现的位置。附加 PlaceContentConfigElementPlaceStandardContentElementPlaceAllContentElement 以指定要渲染的内容。

示例:

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

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

自定义元素:
<gmp-place-details></gmp-place-details>

此类扩展了 HTMLElement

此类实现了 PlaceDetailsElementOptions

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

PlaceDetailsElement
PlaceDetailsElement([options])
参数: 
place
类型:  Place optional
只读。包含当前渲染的地点 ID、位置和视口的 Place 对象。
--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
旨在传达已停用状态或缺席状态的 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
文字和图标在任何界面颜色下的颜色。用于常规文本。
--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
与 surface 颜色相对的互动文字和图标的颜色。用于显示 Google 地图披露声明对话框中的评价数量、链接、网站链接、概览标签页中的图标以及标签栏标题上的(悬停 / 焦点 / 文字颜色)。
--gmp-mat-color-secondary-container
与 Surface 相比,填充色不太显眼,适用于色调按钮等隐性组件。用于“在 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 地图披露声明对话框中的链接。
--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])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  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

以紧凑布局显示地点的详细信息。附加 PlaceDetailsPlaceRequestElementPlaceDetailsLocationRequestElement 以指定要渲染的位置。附加 PlaceContentConfigElementPlaceStandardContentElementPlaceAllContentElement 以指定要渲染的内容。

示例:

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

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

自定义元素:
<gmp-place-details-compact 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
只读。包含当前渲染的地点 ID、位置和视口的 Place 对象。
truncationPreferred
类型:  boolean
默认值false
如果为 true,则截断地点名称和地址以适合单行显示,而不是换行显示。
HTML 属性
  • <gmp-place-details-compact truncation-preferred></gmp-place-details-compact>
--gmp-button-border-color
“在 Google 地图中打开”按钮的边框颜色。
--gmp-button-border-radius
“在 Google 地图中打开”按钮的边框圆角。
--gmp-button-border-width
“在 Google 地图中打开”按钮的边框宽度。
--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
文字和图标在任何界面颜色下的颜色。用于常规文本。
--gmp-mat-color-on-surface-variant
用于在任何 surface 颜色上显示文本和图标的低强调颜色。用于不太强调的文本。
--gmp-mat-color-outline-decorative
非交互式元素的轮廓颜色。用于元素的边框。
--gmp-mat-color-positive
具有积极情感的界面元素的颜色。用于“营业中”状态中的“营业”文本。
--gmp-mat-color-primary
与 surface 颜色相对的互动文字和图标的颜色。用于评价数量以及 Google 地图披露声明对话框中的链接。
--gmp-mat-color-secondary-container
与 Surface 相比,填充色不太显眼,适用于色调按钮等隐性组件。用于“在 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 地图披露声明对话框和照片库中的评价者提供方信息文本中的链接。
--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])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  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

配置 PlaceDetailsCompactElementPlaceDetailsElement 以根据地点对象、ID 或资源名称加载数据。将此元素作为 PlaceDetailsCompactElementPlaceDetailsElement 的子元素附加,以加载指定地点的数据。例如:

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

自定义元素:
<gmp-place-details-place-request place="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])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  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

配置 PlaceDetailsCompactElementPlaceDetailsElement 以根据位置信息加载数据。将此元素作为 PlaceDetailsCompactElementPlaceDetailsElement 的子元素附加,以加载指定位置的数据。例如:

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

自定义元素:
<gmp-place-details-location-request location="lat,lng"></gmp-place-details-location-request>

此类扩展了 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])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener
removeEventListener
removeEventListener(type, listener[, options])
参数: 
返回值:  void
从目标中移除之前通过 addEventListener 注册的事件监听器。请参阅 removeEventListener

PlaceDetailsLocationRequestElementOptions 接口

google.maps.places.PlaceDetailsLocationRequestElementOptions 接口

PlaceDetailsLocationRequestElement 的选项。

location optional
要呈现相应地点的位置。

PlaceSearchElement

google.maps.places.PlaceSearchElement

以列表形式显示地点搜索结果。附加 PlaceTextSearchRequestElementPlaceNearbySearchRequestElement 以指定要呈现结果的请求。附加 PlaceContentConfigElementPlaceStandardContentElementPlaceAllContentElement 以指定要渲染的内容。

示例:

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

如需使用地点搜索元素,请在 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 optional
默认值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
“在 Google 地图中打开”按钮的边框颜色。
--gmp-button-border-radius
“在地图中打开”按钮的边框半径。
--gmp-button-border-width
“在 Google 地图中打开”按钮的边框宽度。
--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
与界面颜色相对的文字和图标颜色。用于标题和对话框内容。
--gmp-mat-color-on-surface-variant
用于在 surface 颜色上显示文字和图标的低强调颜色。用于地点信息。
--gmp-mat-color-outline-decorative
非交互式元素的轮廓颜色。用于容器边框。
--gmp-mat-color-positive
具有积极情感的界面元素的颜色。用于地点的营业时间的“营业”标签。
--gmp-mat-color-primary
与 surface 颜色相对的互动文字和图标的颜色。用于链接、加载指示器和概览图标。
--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])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  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
类型:  PlaceSearchAttributionPosition 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
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])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener
removeEventListener
removeEventListener(type, listener[, options])
参数: 
返回值:  void
从目标中移除之前通过 addEventListener 注册的事件监听器。请参阅 removeEventListener

PlaceNearbySearchRequestElementOptions 接口

google.maps.places.PlaceNearbySearchRequestElementOptions 接口

PlaceNearbySearchRequestElement 的选项。

excludedPrimaryTypes optional
类型:  Array<string> optional
排除主要地点类型。如需了解详情,请参阅 PlaceNearbySearchRequestElement.excludedPrimaryTypesSearchNearbyRequest.excludedPrimaryTypes
excludedTypes optional
类型:  Array<string> optional
排除的地点类型。如需了解详情,请参阅 PlaceNearbySearchRequestElement.excludedTypesSearchNearbyRequest.excludedTypes
includedPrimaryTypes optional
类型:  Array<string> optional
包含的主要地点类型。如需了解详情,请参阅 PlaceNearbySearchRequestElement.includedPrimaryTypesSearchNearbyRequest.includedPrimaryTypes
includedTypes optional
类型:  Array<string> optional
包含的地点类型。如需了解详情,请参阅 PlaceNearbySearchRequestElement.includedTypesSearchNearbyRequest.includedTypes
locationRestriction optional
类型:  Circle|CircleLiteral optional
要搜索的地区。如需了解详情,请参阅 PlaceNearbySearchRequestElement.locationRestrictionSearchNearbyRequest.locationRestriction
maxResultCount optional
类型:  number optional
返回的结果数上限。如需了解详情,请参阅 PlaceNearbySearchRequestElement.maxResultCountSearchNearbyRequest.maxResultCount
rankPreference optional
类型:  SearchNearbyRankPreference optional
响应中结果的排名方式。如需了解详情,请参阅 PlaceNearbySearchRequestElement.rankPreferenceSearchNearbyRankPreference

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
默认值null
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
类型:  LatLngBounds|LatLngBoundsLiteral optional
默认值null
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
HTML 属性
  • <gmp-place-text-search-request use-strict-type-filtering></gmp-place-text-search-request>
addEventListener
addEventListener(type, listener[, options])
参数: 
  • typestring一个区分大小写的字符串,表示要监听的事件类型。
  • listenerEventListener|EventListenerObject 接收通知的对象。必须是函数或具有 handleEvent 方法的对象
  • optionsboolean|AddEventListenerOptions optional 请参阅选项。自定义事件仅支持 capturepassive
返回值:  void
设置一个函数,每当指定事件传递到目标时,系统都会调用该函数。请参阅 addEventListener
removeEventListener
removeEventListener(type, listener[, options])
参数: 
返回值:  void
从目标中移除之前通过 addEventListener 注册的事件监听器。请参阅 removeEventListener

PlaceTextSearchRequestElementOptions 接口

google.maps.places.PlaceTextSearchRequestElementOptions 接口

PlaceTextSearchRequestElement 的选项。

evConnectorTypes optional
类型:  Array<EVConnectorType> optional
首选电动汽车连接器类型的列表。如需了解详情,请参阅 SearchByTextRequest.evSearchOptionsPlaceTextSearchRequestElement.evConnectorTypes
evMinimumChargingRateKw optional
类型:  number optional
所需的最低充电功率(以千瓦为单位)。如需了解详情,请参阅 SearchByTextRequest.evSearchOptionsPlaceTextSearchRequestElement.evMinimumChargingRateKw
includedType optional
类型:  string optional
所请求的地点类型。如需了解详情,请参阅 SearchByTextRequest.includedTypePlaceTextSearchRequestElement.includedType
isOpenNow optional
类型:  boolean optional
用于将搜索范围限制在当前营业的地点。如需了解详情,请参阅 SearchByTextRequest.isOpenNowPlaceTextSearchRequestElement.isOpenNow
locationBias optional
搜索的位置偏向。如需了解详情,请参阅 SearchByTextRequest.locationBiasPlaceTextSearchRequestElement.locationBias
locationRestriction optional
类型:  LatLngBounds|LatLngBoundsLiteral optional
搜索的位置限制。如需了解详情,请参阅 SearchByTextRequest.locationRestrictionPlaceTextSearchRequestElement.locationRestriction
maxResultCount optional
类型:  number optional
返回的结果数上限。如需了解详情,请参阅 SearchByTextRequest.maxResultCountPlaceTextSearchRequestElement.maxResultCount
minRating optional
类型:  number optional
过滤掉平均用户评分严格低于此限制的结果。如需了解详情,请参阅 SearchByTextRequest.minRatingPlaceTextSearchRequestElement.minRating
priceLevels optional
类型:  Array<PriceLevel> optional
用于将搜索范围限制为标记为特定价位的地点。如需了解详情,请参阅 SearchByTextRequest.priceLevelsPlaceTextSearchRequestElement.priceLevels
rankPreference optional
类型:  SearchByTextRankPreference optional
响应中结果的排名方式。如需了解详情,请参阅 SearchByTextRequest.rankPreferencePlaceTextSearchRequestElement.rankPreference
textQuery optional
类型:  string optional
用于文本搜索的文本查询。如需了解详情,请参阅 SearchByTextRequest.textQueryPlaceTextSearchRequestElement.textQuery
useStrictTypeFiltering optional
类型:  boolean optional

自动补全

google.maps.places.Autocomplete

一种根据用户输入的文本提供地点预测的 widget。它会附加到类型为 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)
参数: 
  • fieldsArray<string> optional
返回值:无
设置成功检索到详情时要在详情响应中包含的地点字段。如需查看字段列表,请参阅 PlaceResult
setOptions
setOptions(options)
参数: 
返回值:无
setTypes
setTypes(types)
参数: 
  • typesArray<string> optional 要包含的预测类型。
返回值:无
设置要返回的预测类型。如需了解支持的类型,请参阅 开发者指南。如果未指定任何类型,系统将返回所有类型。
继承自addListenerbindTogetnotifysetsetValuesunbindunbindAll
place_changed
function()
参数:None
当用户选择的地点有 PlaceResult 可用时,系统会触发此事件。
如果用户输入了控件未建议的地点名称并按下了 Enter 键,或者地点详情请求失败,则 PlaceResult 会在 name 属性中包含用户输入的内容,而不会定义其他属性。

AutocompleteOptions 接口

google.maps.places.AutocompleteOptions 接口

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

bounds optional
类型:  LatLngBounds|LatLngBoundsLiteral 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

一种根据用户输入的文本提供查询预测的 widget。它会附加到类型为 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)
参数: 
返回值:无
设置用于对查询预测进行偏向的区域。结果只会偏向于此区域,而不会完全限制在此区域内。
继承自addListenerbindTogetnotifysetsetValuesunbindunbindAll
places_changed
function()
参数:None
当用户选择查询时会触发此事件,getPlaces 应用于获取新地点。

SearchBoxOptions 接口

google.maps.places.SearchBoxOptions 接口

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

bounds optional
类型:  LatLngBounds|LatLngBoundsLiteral optional
要将查询预测结果偏向的区域。预测偏向于(但不限于)以这些边界为目标的查询。