New pricing changes went into effect on July 16, 2018. For more information, check out the Guide for Existing Users.

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.

Constructor
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.
Methods
close
close()
Parameters:  None
Return Value:  None
Closes this InfoWindow by removing it from the DOM structure.
getContent
getContent()
Parameters:  None
Return Value:  string|Node
getPosition
getPosition()
Parameters:  None
Return Value:  LatLng
getZIndex
getZIndex()
Parameters:  None
Return Value:  number
open
open([map, anchor])
Parameters: 
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 LatLng position property and optionally a Point anchorPoint property for calculating the pixelOffset (see InfoWindowOptions). The anchorPoint is the offset from the anchor's position to the tip of the InfoWindow.
setContent
setContent(content)
Parameters: 
  • contentstring|Node
Return Value:  None
setOptions
setOptions(options)
Parameters: 
Return Value:  None
setPosition
setPosition(position)
Parameters: 
Return Value:  None
setZIndex
setZIndex(zIndex)
Parameters: 
  • zIndexnumber
Return Value:  None
Events
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 the InfoWindow's content is attached to the DOM. You may wish to monitor this event if you are building out your info window content dynamically.
position_changed
function()
Arguments:  None
This event is fired when the position property changes.
zindex_changed
function()
Arguments:  None
This event is fired when the InfoWindow's zIndex changes.

InfoWindowOptions interface

google.maps.InfoWindowOptions interface

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

Properties
content
Type:  string|Node
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.
disableAutoPan
Type:  boolean
Disable auto-pan on open. By default, the info window will pan the map so that it is fully visible when it opens.
maxWidth
Type:  number
Maximum width of the infowindow, regardless of content's width. This value is only considered if it is set before a call to open. To change the maximum width when changing content, call close, setOptions, and then open.
pixelOffset
Type:  Size
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, the pixelOffset will be calculated from the anchor's anchorPoint property.
position
The LatLng at which to display this InfoWindow. If the InfoWindow is opened with an anchor, the anchor's position will be used instead.
zIndex
Type:  number
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.

Envoyer des commentaires concernant…

Maps JavaScript API
Besoin d'aide ? Consultez notre page d'assistance.