Info Window

InfoWindow class

google.maps.InfoWindow class

An overlay that looks like a bubble and is often connected to a marker.

This class extends MVCObject.

Access by callingconst {InfoWindow} = await google.maps.importLibrary( "maps" )orconst {InfoWindow} = await google.maps.importLibrary( "streetView" ).SeeLibraries in the Maps JavaScript API.

InfoWindow
InfoWindow([opts])
Parameters:
Creates an info window with the given options. An InfoWindow can be placed on a map at a particular position or above a marker, depending on what is specified in the options. Unless auto-pan is disabled, an InfoWindow will pan the map to make itself visible when it is opened. After constructing an InfoWindow, you must call open to display it on the map. The user can click the close button on the InfoWindow to remove it from the map, or the developer can call close() for the same effect.
isOpen
Type:boolean
Checks if the InfoWindow is open.
close
close()
Parameters:None
Return Value:None
Closes this InfoWindow by removing it from the DOM structure.
focus
focus()
Parameters:None
Return Value:None
Sets focus on thisInfoWindow.You may wish to consider using this method along with avisibleevent to make sure thatInfoWindowis visible before setting focus on it. AnInfoWindowthat is not visible cannot be focused.
getContent
getContent()
Parameters:None
Return Value:string|Element|Text|null|undefinedThe content of this InfoWindow. The same as what was previously set as the content.
getHeaderContent
getHeaderContent()
Parameters:None
Return Value:string|Element|Text|null|undefinedThe header content of this InfoWindow. SeeInfoWindowOptions.headerContent.
getHeaderDisabled
getHeaderDisabled()
Parameters:None
Return Value:boolean|undefinedWhether the whole header row is disabled or not. SeeInfoWindowOptions.headerDisabled.
getPosition
getPosition()
Parameters:None
Return Value:LatLng|null|undefinedThe LatLng position of this InfoWindow.
getZIndex
getZIndex()
Parameters:None
Return Value:numberThe zIndex of this InfoWindow.
open
open([options, anchor])
Parameters:
  • options:InfoWindowOpenOptions|Map|StreetViewPanoramaoptionalEither an InfoWindowOpenOptions object (recommended) or the map|panorama on which to render this InfoWindow.
  • anchor:MVCObject|AdvancedMarkerElementoptionalThe anchor to which this InfoWindow will be positioned. If the anchor is non-null, the InfoWindow will be positioned at the top-center of the anchor. The InfoWindow will be rendered on the same map or panorama as the anchor(when available).
Return Value:None
Opens this InfoWindow on the given map. Optionally, an InfoWindow can be associated with an anchor. In the core API, the only anchor is the Marker class. However, an anchor can be any MVCObject that exposes a LatLngpositionproperty and optionally a PointanchorPointproperty for calculating thepixelOffset(see InfoWindowOptions). TheanchorPointis the offset from the anchor's position to the tip of the InfoWindow. It is recommended to use theInfoWindowOpenOptionsinterface as the single argument for this method. To prevent changing browser focus on open, setInfoWindowOpenOptions.shouldFocustofalse.
setContent
setContent([content])
Parameters:
  • content:string|Element|TextoptionalThe content to be displayed by this InfoWindow.
Return Value:None
setHeaderContent
setHeaderContent([headerContent])
Parameters:
Return Value:None
setHeaderDisabled
setHeaderDisabled([headerDisabled])
Parameters:
Return Value:None
setOptions
setOptions([options])
Parameters:
Return Value:None
setPosition
setPosition([position])
Parameters:
  • position:LatLng|LatLngLiteraloptionalThe LatLng position at which to display this InfoWindow.
Return Value:None
setZIndex
setZIndex(zIndex)
Parameters:
  • zIndex:numberThe z-index for this InfoWindow. An InfoWindow with a greater z-index will be displayed in front of all other InfoWindows with a lower z-index.
Return Value:None
Inherited: addListener, bindTo, get, notify, set, setValues, unbind, unbindAll
close
function()
Arguments:None
This event is fired whenever theInfoWindowcloses. For example, this could be from calling theInfoWindow.closemethod, pressing the escape key to close the InfoWindow, or clicking the close button or moving the InfoWindow to another map.
closeclick
function()
Arguments:None
This event is fired when the close button was clicked.
content_changed
function()
Arguments:None
This event is fired when the content property changes.
domready
function()
Arguments:None
This event is fired when the<div>containing theInfoWindow's content is attached to the DOM. You may wish to monitor this event if you are building out your info window content dynamically.
headercontent_changed
function()
Arguments:None
This event is fired when the headerContent property changes.
headerdisabled_changed
function()
Arguments:None
This event is fired when the headerDisabled property changes.
position_changed
function()
Arguments:None
This event is fired when the position property changes.
visible
function()
Arguments:None
This event is fired when theInfoWindowis fully visible. This event is not fired whenInfoWindowis panned off and then back on screen.
zindex_changed
function()
Arguments:None
This event is fired when theInfoWindow's zIndex changes.

InfoWindowOptions interface

google.maps.InfoWindowOptions interface

InfoWindowOptions object used to define the properties that can be set on a InfoWindow.

ariaLabeloptional
Type:stringoptional
AriaLabel to assign to the InfoWindow.
contentoptional
Type:string|Element|Textoptional
Content to display in the InfoWindow. This can be an HTML element, a plain-text string, or a string containing HTML. The InfoWindow will be sized according to the content. To set an explicit size for the content, set content to be a HTML element with that size.
disableAutoPanoptional
Type:booleanoptional
Default:false
Disable panning the map to make the InfoWindow fully visible when it opens.
headerContentoptional
Type:string|Element|Textoptional
The content to display in the InfoWindow header row. This can be an HTML element, or a string of plain text. The InfoWindow will be sized according to the content. To set an explicit size for the header content, set headerContent to be a HTML element with that size.
headerDisabledoptional
Type:booleanoptional
Disables the whole header row in the InfoWindow. When set to true, the header will be removed so that the header content and the close button will be hidden.
maxWidthoptional
Type:numberoptional
Maximum width of the InfoWindow, regardless of content's width. This value is only considered if it is set before a call toopen().To change the maximum width when changing content, callclose(),setOptions(),and thenopen().
minWidthoptional
Type:numberoptional
Minimum width of the InfoWindow, regardless of the content's width. When using this property, it is strongly recommended to set theminWidthto a value less than the width of the map (in pixels). This value is only considered if it is set before a call toopen().To change the minimum width when changing content, callclose(),setOptions(),and thenopen().
pixelOffsetoptional
Type:Sizeoptional
The offset, in pixels, of the tip of the info window from the point on the map at whose geographical coordinates the info window is anchored. If an InfoWindow is opened with an anchor, thepixelOffsetwill be calculated from the anchor'sanchorPointproperty.
positionoptional
Type:LatLng|LatLngLiteraloptional
The LatLng at which to display this InfoWindow. If the InfoWindow is opened with an anchor, the anchor's position will be used instead.
zIndexoptional
Type:numberoptional
All InfoWindows are displayed on the map in order of their zIndex, with higher values displaying in front of InfoWindows with lower values. By default, InfoWindows are displayed according to their latitude, with InfoWindows of lower latitudes appearing in front of InfoWindows at higher latitudes. InfoWindows are always displayed in front of markers.

InfoWindowOpenOptions interface

google.maps.InfoWindowOpenOptions interface

Options for opening an InfoWindow

anchoroptional
The anchor to which this InfoWindow will be positioned. If the anchor is non-null, the InfoWindow will be positioned at the top-center of the anchor. The InfoWindow will be rendered on the same map or panorama as the anchor(when available).
mapoptional
Type:Map|StreetViewPanoramaoptional
The map or panorama on which to render this InfoWindow.
shouldFocusoptional
Type:booleanoptional
Whether or not focus should be moved inside the InfoWindow when it is opened. When this property is unset or when it is set tonullorundefined,a heuristic is used to decide whether or not focus should be moved. It is recommended to explicitly set this property to fit your needs as the heuristic is subject to change and may not work well for all use cases.