Maps
MapElement class
class
google.maps.MapElement
extends HTMLElement
implements MapElementOptions
library "maps"
MapElement is an HTMLElement subclass for rendering maps. After loading the maps library, a map can be created in HTML. For example:
<gmp-map center="37.4220656,-122.0840897" zoom="10" map-id="DEMO_MAP_ID">
<button slot="control-block-start-inline-end">Custom Control</button>
</gmp-map> Internally, it uses Map, which can be accessed with the MapElement.innerMap property.
<gmp-map center="lat,lng" heading-interaction-disabled internal-usage-attribution-ids="id1 id2" map-id="string" rendering-type="value-name" tilt-interaction-disabled zoom="number"> </gmp-map>
const {MapElement} = await google.maps.importLibrary("maps");
Constructor | |
|---|---|
MapElement |
Parameters:
|
Properties | |
|---|---|
center
attr: center |
Type: The center latitude/longitude of the map. HTML attribute: |
headingInteractionDisabled
attr: heading-interaction-disabled |
Type: Default: Whether the map should allow user control of the camera heading (rotation). This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available). HTML attribute: |
innerMap |
Type: A reference to the |
internalUsageAttributionIds
attr: internal-usage-attribution-ids |
Input type: Default: Adds a usage attribution ID to the initializer, which helps Google understand which libraries and samples are helpful to developers, such as usage of a marker clustering library. To opt out of sending the usage attribution ID, it is safe to delete this property or replace the value with an empty string. Only unique values will be sent. Changes to this value after instantiation may be ignored. HTML attribute: |
mapId
attr: map-id |
Type: The map ID of the map. This parameter cannot be set or changed after a map is instantiated. HTML attribute: |
renderingType
attr: rendering-type |
Type: Default: Whether the map should be a raster or vector map. This parameter cannot be set or changed after a map is instantiated. If not set, then the cloud configuration for the map ID will determine the rendering type (if available). Please note that vector maps may not be available for all devices and browsers and the map will fall back to a raster map as needed. HTML attribute: |
tiltInteractionDisabled
attr: tilt-interaction-disabled |
Type: Default: Whether the map should allow user control of the camera tilt. This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available). HTML attribute: |
zoom
attr: zoom |
Type: The zoom level of the map. Valid zoom values are numbers from zero up to the supported maximum zoom level. Larger zoom values correspond to a higher resolution. HTML attribute: |
Methods | |
|---|---|
Inherited:
addEventListener,
removeEventListener
|
Events | |
|---|---|
gmp-zoomchange |
Arguments:
This event is fired when the map zoom property changes. |
MapElementOptions interface
interface
google.maps.MapElementOptions
implemented by MapElement
MapElementOptions object used to define the properties that can be set on a MapElement.
Properties | |
|---|---|
center
optional |
Type: See |
headingInteractionDisabled
optional |
Type: |
internalUsageAttributionIds
optional |
Type: |
mapId
optional |
Type: See |
renderingType
optional |
Type: |
tiltInteractionDisabled
optional |
Type: |
zoom
optional |
Type: See |
ZoomChangeEvent class
class
google.maps.ZoomChangeEvent
extends Event
library "maps"
This event is created from monitoring zoom change.
const {ZoomChangeEvent} = await google.maps.importLibrary("maps");
Map class
class
google.maps.Map
extends MVCObject
library "maps"
const {Map} = await google.maps.importLibrary("maps");
Constructor | |
|---|---|
Map |
Parameters:
Creates a new map inside of the given HTML container, which is typically a |
Constants | |
|---|---|
DEMO_MAP_ID |
Map ID which can be used for code samples which require a map ID. This map ID is not intended for use in production applications and cannot be used for features which require cloud configuration (such as Cloud Styling). |
Properties | |
|---|---|
controls |
Type: Additional controls to attach to the map. To add a control to the map, add the control's |
data |
Type: An instance of |
mapTypes |
Type: A registry of |
overlayMapTypes |
Additional map types to overlay. Overlay map types will display on top of the base map they are attached to, in the order in which they appear in the |
Methods | |
|---|---|
fitBounds |
Parameters:
Return Value: None Sets the viewport to contain the given bounds. |
getBounds |
Parameters: None Return Value: Returns the lat/lng bounds of the current viewport. If more than one copy of the world is visible, the bounds range in longitude from -180 to 180 degrees inclusive. If the map is not yet initialized or center and zoom have not been set then the result is |
getCenter |
Parameters: None Return Value: Returns the position displayed at the center of the map. Note that this |
getClickableIcons |
Parameters: None Return Value: Returns the clickability of the map icons. A map icon represents a point of interest, also known as a POI. If the returned value is |
|
Parameters:
Return Value: Returns the |
getDiv |
Parameters: None Return Value: |
getFeatureLayer |
Parameters:
Return Value: Returns the |
getHeading |
Parameters: None Return Value: Returns the compass heading of the map. The heading value is measured in degrees (clockwise) from cardinal direction North. If the map is not yet initialized then the result is |
getHeadingInteractionEnabled |
Parameters: None Return Value: Returns whether heading interactions are enabled. This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available). |
getInternalUsageAttributionIds |
Parameters: None Return Value: Returns the list of usage attribution IDs, which help Google understand which libraries and samples are helpful to developers, such as usage of a marker clustering library. |
getMapCapabilities |
Parameters: None Return Value: Informs the caller of the current capabilities available to the map based on the map ID that was provided. |
getMapTypeId |
Parameters: None Return Value: |
getProjection |
Parameters: None Return Value: Returns the current |
getRenderingType |
Parameters: None Return Value: Returns the current RenderingType of the map. |
getStreetView |
Parameters: None Return Value: Returns the default |
getTilt |
Parameters: None Return Value: Returns the current angle of incidence of the map, in degrees from the viewport plane to the map plane. For raster maps, the result will be |
getTiltInteractionEnabled |
Parameters: None Return Value: Returns whether tilt interactions are enabled. This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available). |
getZoom |
Parameters: None Return Value: Returns the zoom of the map. If the zoom has not been set then the result is |
moveCamera |
Parameters:
Return Value: None Immediately sets the map's camera to the target camera options, without animation. |
panBy |
Parameters:
Return Value: None Changes the center of the map by the given distance in pixels. If the distance is less than both the width and height of the map, the transition will be smoothly animated. Note that the map coordinate system increases from west to east (for x values) and north to south (for y values). |
panTo |
Parameters:
Return Value: None Changes the center of the map to the given |
panToBounds |
Parameters:
Return Value: None Pans the map by the minimum amount necessary to contain the given |
setCenter |
Parameters:
Return Value: None |
setClickableIcons |
Parameters:
Return Value: None Controls whether the map icons are clickable or not. A map icon represents a point of interest, also known as a POI. To disable the clickability of map icons, pass a value of |
setHeading |
Parameters:
Return Value: None Sets the compass heading for map measured in degrees from cardinal direction North. For raster maps, this method only applies to aerial imagery. |
setHeadingInteractionEnabled |
Parameters:
Return Value: None Sets whether heading interactions are enabled. This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available). |
setMapTypeId |
Parameters:
Return Value: None |
setOptions |
Parameters:
Return Value: None |
setRenderingType |
Parameters:
Return Value: None Sets the current RenderingType of the map. |
setStreetView |
Parameters:
Return Value: None Binds a |
setTilt |
Parameters:
Return Value: None For vector maps, sets the angle of incidence of the map. The allowed values are restricted depending on the zoom level of the map. For raster maps, controls the automatic switching behavior for the angle of incidence of the map. The only allowed values are |
setTiltInteractionEnabled |
Parameters:
Return Value: None Sets whether tilt interactions are enabled. This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available). |
setZoom |
Parameters:
Return Value: None Sets the zoom of the map. |
Inherited:
addListener,
bindTo,
get,
notify,
set,
setValues,
unbind,
unbindAll
| |
Events | |
|---|---|
bounds_changed |
Arguments: None This event is fired when the viewport bounds have changed. |
center_changed |
Arguments: None This event is fired when the map center property changes. |
click |
Arguments:
This event is fired when the user clicks on the map. A MapMouseEvent with properties for the clicked location is returned unless a place icon was clicked, in which case an IconMouseEvent with a place ID is returned. IconMouseEvent and MapMouseEvent are identical, except that IconMouseEvent has the place ID field. The event can always be treated as an MapMouseEvent when the place ID is not important. The click event is not fired if a marker or info window was clicked. |
contextmenu |
Arguments:
This event is fired when the DOM contextmenu event is fired on the map container. |
dblclick |
Arguments:
This event is fired when the user double-clicks on the map. Note that the click event will sometimes fire once and sometimes twice, right before this one. |
drag |
Arguments: None This event is repeatedly fired while the user drags the map. |
dragend |
Arguments: None This event is fired when the user stops dragging the map. Note: dragend is NOT fired when the user stops panning the map using the keyboard. Please use the |
dragstart |
Arguments: None This event is fired when the user starts dragging the map. |
heading_changed |
Arguments: None This event is fired when the map heading property changes. |
idle |
Arguments: None This event is fired when the map becomes idle after panning or zooming. |
isfractionalzoomenabled_changed |
Arguments: None This event is fired when the isFractionalZoomEnabled property has changed. |
mapcapabilities_changed |
Arguments: None This event is fired when the map capabilities change. |
maptypeid_changed |
Arguments: None This event is fired when the mapTypeId property changes. |
mousemove |
Arguments:
This event is fired whenever the user's mouse moves over the map container. |
mouseout |
Arguments:
This event is fired when the user's mouse exits the map container. |
mouseover |
Arguments:
This event is fired when the user's mouse enters the map container. |
projection_changed |
Arguments: None This event is fired when the projection has changed. |
renderingtype_changed |
Arguments: None This event is fired when the renderingType has changed. |
tilesloaded |
Arguments: None This event is fired when the visible tiles have finished loading. |
tilt_changed |
Arguments: None This event is fired when the map tilt property changes. |
zoom_changed |
Arguments: None This event is fired when the map zoom property changes. |
|
Arguments:
This event is fired when the user right-clicks on the map. |
MapOptions interface
interface
google.maps.MapOptions
MapOptions object used to define the properties that can be set on a Map.
Properties | |
|---|---|
backgroundColor
optional |
Type: Color used for the background of the Map div. This color will be visible when tiles have not yet loaded as the user pans. This option can only be set when the map is initialized. |
cameraControl
optional |
Type: The enabled/disabled state of the Camera control. |
cameraControlOptions
optional |
Type: The display options for the Camera control. |
center
optional |
Type: The initial Map center. |
clickableIcons
optional |
Type: Default: When |
colorScheme
optional |
Type: Default: The initial Map color scheme. This option can only be set when the map is initialized. |
controlSize
optional |
Type: Size in pixels of the controls appearing on the map. This value must be supplied directly when creating the Map, updating this value later may bring the controls into an |
disableDefaultUI
optional |
Type: Enables/disables all default UI buttons. May be overridden individually. Does not disable the keyboard controls, which are separately controlled by the |
disableDoubleClickZoom
optional |
Type: Enables/disables zoom and center on double click. Enabled by default. Note: This property is not recommended. To disable zooming on double click, you can use the |
optional |
Type: If |
draggableCursor
optional |
Type: The name or url of the cursor to display when mousing over a draggable map. This property uses the css |
draggingCursor
optional |
Type: The name or url of the cursor to display when the map is being dragged. This property uses the css |
fullscreenControl
optional |
Type: The enabled/disabled state of the Fullscreen control. |
fullscreenControlOptions
optional |
Type: The display options for the Fullscreen control. |
gestureHandling
optional |
Type: This setting controls how the API handles gestures on the map. Allowed values:
|
heading
optional |
Type: The heading for aerial imagery in degrees measured clockwise from cardinal direction North. Headings are snapped to the nearest available angle for which imagery is available. |
headingInteractionEnabled
optional |
Type: Default: Whether the map should allow user control of the camera heading (rotation). This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available). |
internalUsageAttributionIds
optional |
Type: Default: Adds a usage attribution ID to the initializer, which helps Google understand which libraries and samples are helpful to developers, such as usage of a marker clustering library. To opt out of sending the usage attribution ID, it is safe to delete this property or replace the value with an empty string. Only unique values will be sent. Changes to this value after instantiation may be ignored. |
isFractionalZoomEnabled
optional |
Type: Default: Whether the map should allow fractional zoom levels. Listen to |
keyboardShortcuts
optional |
Type: If |
mapId
optional |
Type: The map ID of the map. This parameter cannot be set or changed after a map is instantiated. |
mapTypeControl
optional |
Type: The initial enabled/disabled state of the Map type control. |
mapTypeControlOptions
optional |
Type: The initial display options for the Map type control. |
mapTypeId
optional |
Type: The initial Map mapTypeId. Defaults to |
maxZoom
optional |
Type: The maximum zoom level which will be displayed on the map. If omitted, or set to |
minZoom
optional |
Type: The minimum zoom level which will be displayed on the map. If omitted, or set to |
noClear
optional |
Type: If |
optional |
Type: The enabled/disabled state of the Pan control. |
optional |
Type: The display options for the Pan control. |
renderingType
optional |
Type: Default: Whether the map should be a raster or vector map. This parameter cannot be set or changed after a map is instantiated. If not set, then the cloud configuration for the map ID will determine the rendering type (if available). Please note that vector maps may not be available for all devices and browsers and the map will fall back to a raster map as needed. |
restriction
optional |
Type: Defines a boundary that restricts the area of the map accessible to users. When set, a user can only pan and zoom while the camera view stays inside the limits of the boundary. |
rotateControl
optional |
Type: The enabled/disabled state of the Rotate control. |
rotateControlOptions
optional |
Type: The display options for the Rotate control. |
scaleControl
optional |
Type: The initial enabled/disabled state of the Scale control. |
scaleControlOptions
optional |
Type: The initial display options for the Scale control. |
scrollwheel
optional |
Type: If Note: This property is not recommended. To disable zooming using scrollwheel, you can use the |
streetView
optional |
Type: A |
streetViewControl
optional |
Type: The initial enabled/disabled state of the Street View Pegman control. This control is part of the default UI, and should be set to |
streetViewControlOptions
optional |
Type: The initial display options for the Street View Pegman control. |
styles
optional |
Type: Styles to apply to each of the default map types. Note that for |
tilt
optional |
Type: For vector maps, sets the angle of incidence of the map. The allowed values are restricted depending on the zoom level of the map. For raster maps, controls the automatic switching behavior for the angle of incidence of the map. The only allowed values are |
tiltInteractionEnabled
optional |
Type: Default: Whether the map should allow user control of the camera tilt. This option is only in effect when the map is a vector map. If not set in code, then the cloud configuration for the map ID will be used (if available). |
zoom
optional |
Type: The initial Map zoom level. Valid zoom values are numbers from zero up to the supported maximum zoom level. Larger zoom values correspond to a higher resolution. |
zoomControl
optional |
Type: The enabled/disabled state of the Zoom control. |
zoomControlOptions
optional |
Type: The display options for the Zoom control. |
MapTypeStyle interface
interface
google.maps.MapTypeStyle
The MapTypeStyle is a collection of selectors and stylers that define how the map should be styled. Selectors specify the map features and/or elements that should be affected, and stylers specify how those features and elements should be modified. For details, see the style reference.
Properties | |
|---|---|
stylers |
The style rules to apply to the selected map features and elements. The rules are applied in the order that you specify in this array. For guidelines on usage and allowed values, see the style reference. |
elementType
optional |
Type: The element to which a styler should be applied. An element is a visual aspect of a feature on the map. Example: a label, an icon, the stroke or fill applied to the geometry, and more. Optional. If |
featureType
optional |
Type: The feature, or group of features, to which a styler should be applied. Optional. If |
MapMouseEvent interface
interface
google.maps.MapMouseEvent
extended by Data.MouseEvent, FeatureMouseEvent, IconMouseEvent, PolyMouseEvent
This object is returned from various mouse events on the map and overlays, and contains all the fields shown below.
Properties | |
|---|---|
domEvent |
The corresponding native DOM event. Developers should not rely on |
latLng
optional |
Type: The latitude/longitude that was below the cursor when the event occurred. |
Methods | |
|---|---|
stop |
Parameters: None Return Value: Prevents this event from propagating further. |
IconMouseEvent interface
interface
google.maps.IconMouseEvent
extends MapMouseEvent
This object is sent in an event when a user clicks on an icon on the map. The place ID of this place is stored in the placeId member. To prevent the default info window from showing up, call the stop() method on this event to prevent it being propagated. Learn more about place IDs in the Places API developer guide.
Properties | |
|---|---|
placeId
optional |
Type: The place ID of the place that was clicked. This place ID can be used to query more information about the feature that was clicked. Learn more about place IDs in the Places API developer guide. |
Inherited:
domEvent,
latLng
| |
Methods | |
|---|---|
Inherited:
stop
|
ColorScheme constants
constants
google.maps.ColorScheme
library "core"
Identifiers for map color schemes. Specify these by value, or by using the constant's name. For example, 'FOLLOW_SYSTEM' or google.maps.ColorScheme.FOLLOW_SYSTEM.
These constants are also usable as strings. In TypeScript, the string literals are defined by the ColorSchemeString type.
const {ColorScheme} = await google.maps.importLibrary("core");
Constants | |
|---|---|
DARK |
The dark color scheme for a map. |
FOLLOW_SYSTEM |
The color scheme is selected based on system preferences, which are checked once at method execution time. |
LIGHT |
The light color scheme for a map. Default value for legacy Maps JS. |
MapTypeId constants
constants
google.maps.MapTypeId
library "maps"
Identifiers for common MapTypes. Specify these by value, or by using the constant's name. For example, 'satellite' or google.maps.MapTypeId.SATELLITE.
These constants are also usable as strings. In TypeScript, the string literals are defined by the MapTypeIdString type.
const {MapTypeId} = await google.maps.importLibrary("maps");
Constants | |
|---|---|
HYBRID |
This map type displays a transparent layer of major streets on satellite images. |
ROADMAP |
This map type displays a normal street map. |
SATELLITE |
This map type displays satellite images. |
TERRAIN |
This map type displays maps with physical features such as terrain and vegetation. |
MapTypeRegistry class
class
google.maps.MapTypeRegistry
extends MVCObject
library "maps"
A registry for MapType instances, keyed by MapType id.
const {MapTypeRegistry} = await google.maps.importLibrary("maps");
Constructor | |
|---|---|
MapTypeRegistry |
Parameters: None The |
Methods | |
|---|---|
set |
Parameters:
Return Value: None Sets the registry to associate the passed string identifier with the passed MapType. |
Inherited:
addListener,
bindTo,
get,
notify,
setValues,
unbind,
unbindAll
| |
MapRestriction interface
interface
google.maps.MapRestriction
A restriction that can be applied to the Map. The map's viewport will not exceed these restrictions.
Properties | |
|---|---|
latLngBounds |
When set, a user can only pan and zoom inside the given bounds. Bounds can restrict both longitude and latitude, or can restrict latitude only. For latitude-only bounds use west and east longitudes of -180 and 180, respectively, for example, |
strictBounds
optional |
Type: Bounds can be made more restrictive by setting the |
TrafficLayer class
class
google.maps.TrafficLayer
extends MVCObject
library "maps"
A traffic layer.
const {TrafficLayer} = await google.maps.importLibrary("maps");
Constructor | |
|---|---|
TrafficLayer |
Parameters:
A layer that displays current road traffic. |
Methods | |
|---|---|
getMap |
Parameters: None Return Value: Returns the map on which this layer is displayed. |
setMap |
Parameters:
Return Value: None Renders the layer on the specified map. If map is set to |
setOptions |
Parameters:
Return Value: None |
Inherited:
addListener,
bindTo,
get,
notify,
set,
setValues,
unbind,
unbindAll
| |
TrafficLayerOptions interface
interface
google.maps.TrafficLayerOptions
TrafficLayerOptions object used to define the properties that can be set on a TrafficLayer.
Properties | |
|---|---|
autoRefresh
optional |
Type: Default: Whether the traffic layer refreshes with updated information automatically. |
map
optional |
Type: Map on which to display the traffic layer. |
TransitLayer class
class
google.maps.TransitLayer
extends MVCObject
library "maps"
A transit layer.
const {TransitLayer} = await google.maps.importLibrary("maps");
Constructor | |
|---|---|
TransitLayer |
Parameters: None A layer that displays transit lines. |
Methods | |
|---|---|
getMap |
Parameters: None Return Value: Returns the map on which this layer is displayed. |
setMap |
Parameters:
Return Value: Renders the layer on the specified map. If map is set to |
Inherited:
addListener,
bindTo,
get,
notify,
set,
setValues,
unbind,
unbindAll
| |
BicyclingLayer class
class
google.maps.BicyclingLayer
extends MVCObject
library "maps"
A layer showing bike lanes and paths.
const {BicyclingLayer} = await google.maps.importLibrary("maps");
Constructor | |
|---|---|
BicyclingLayer |
Parameters: None A layer that displays bike lanes and paths and demotes large roads. |
Methods | |
|---|---|
getMap |
Parameters: None Return Value: Returns the map on which this layer is displayed. |
setMap |
Parameters:
Return Value: Renders the layer on the specified map. If map is set to |
Inherited:
addListener,
bindTo,
get,
notify,
set,
setValues,
unbind,
unbindAll
| |
CameraOptions interface
interface
google.maps.CameraOptions
extended by CameraParams
Used for setting the map's camera options.
Properties | |
|---|---|
center
optional |
Type: |
heading
optional |
Type: |
tilt
optional |
Type: |
zoom
optional |
Type: |
VisibleRegion interface
interface
google.maps.VisibleRegion
Contains the four points defining the four-sided polygon that is the visible region of the map. On a vector map this polygon can be a trapezoid instead of a rectangle, when a vector map has tilt.
Properties | |
|---|---|
farLeft |
Type: |
farRight |
Type: |
latLngBounds |
Type: The smallest bounding box that includes the visible region. |
nearLeft |
Type: |
nearRight |
Type: |
RenderingType constants
constants
google.maps.RenderingType
library "maps"
These constants are also usable as strings. In TypeScript, the string literals are defined by the RenderingTypeString type.
const {RenderingType} = await google.maps.importLibrary("maps");
Constants | |
|---|---|
RASTER |
Indicates that the map is a raster map. |
UNINITIALIZED |
Indicates that it is unknown yet whether the map is vector or raster, because the map has not finished initializing yet. |
VECTOR |
Indicates that the map is a vector map. |
MapCapabilities interface
interface
google.maps.MapCapabilities
Object containing a snapshot of what capabilities are currently available for the Map. Note that this does not necessarily mean that relevant modules are loaded or initialized, but rather that the current map has permission to use these APIs. See the properties for a list of possible capabilities.
Properties | |
|---|---|
isAdvancedMarkersAvailable
optional |
Type: If true, this map is configured properly to allow for the use of advanced markers. Note that you must still import the |
isDataDrivenStylingAvailable
optional |
Type: If true, this map is configured properly to allow for the use of data-driven styling for at least one FeatureLayer. See https://goo.gle/gmp-data-driven-styling and https://goo.gle/gmp-FeatureLayerIsAvailable for more information. |
isWebGLOverlayViewAvailable
optional |
Type: If true, this map is configured properly to allow for the use of |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-08-11 UTC.