3D Maps

Map3DElement class

google.maps.maps3d.Map3DElement class

Map3DElement is an HTML interface for the 3D Map view.

Custom element:
<gmp-map-3d center= "lat,lng,altitude" default-labels-disabled heading= "number" max-altitude= "number" max-heading= "number" max-tilt= "number" min-altitude= "number" min-heading= "number" min-tilt= "number" range= "number" roll= "number" tilt= "number" ></gmp-map-3d>

This class extends HTMLElement.

This class implements Map3DElementOptions.

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

Map3DElement
Map3DElement([options])
Parameters:
bounds
When set, restricts the position of the camera within the specified lat/lng bounds. Note that objects outside the bounds are still rendered. Bounds can restrict both longitude and latitude, or can restrict either latitude or longitude only. For latitude-only bounds use west and east longitudes of-180and180,respectively. For longitude-only bounds use north and south latitudes of90and-90,respectively.
center
The center of the map given as a LatLngAltitude, where altitude is in meters above ground level. Note that this is not necessarily where the camera is located, as therangefield affects the camera's distance from the map center. If not set, defaults to{lat: 0, lng: 0, altitude: 63170000}.63170000 meters is a maximum allowed altitude (Earth radius multiplied by 10).
HTML attribute:
  • <gmp-map-3d center= "lat,lng,altitude" ></gmp-map-3d>
defaultLabelsDisabled
Type:booleanoptional
Default:false
Whentrue,default map labels aren't rendered.
HTML attribute:
  • <gmp-map-3d default-labels-disabled></gmp-map-3d>
heading
Type:numberoptional
The compass heading of the map, in degrees, where due north is zero. When there is no tilt, any roll will be interpreted as heading.
HTML attribute:
  • <gmp-map-3d heading= "number" ></gmp-map-3d>
maxAltitude
Type:numberoptional
The maximum altitude above the ground which will be displayed on the map. A valid value is between0and63170000meters (Earth radius multiplied by 10).
HTML attribute:
  • <gmp-map-3d max-altitude= "number" ></gmp-map-3d>
maxHeading
Type:numberoptional
The maximum angle of heading (rotation) of the map. A valid value is between0and360degrees.minHeadingandmaxHeadingrepresent an interval of <=360degrees in which heading gestures will be allowed.minHeading = 180andmaxHeading = 90will allow heading in[0, 90]and heading in[180, 360].minHeading = 90andmaxHeading = 180will allow heading in[90, 180].
HTML attribute:
  • <gmp-map-3d max-heading= "number" ></gmp-map-3d>
maxTilt
Type:numberoptional
The maximum angle of incidence of the map. A valid value is between0and90degrees.
HTML attribute:
  • <gmp-map-3d max-tilt= "number" ></gmp-map-3d>
minAltitude
Type:numberoptional
The minimum altitude above the ground which will be displayed on the map. A valid value is between0and63170000meters (Earth radius multiplied by 10).
HTML attribute:
  • <gmp-map-3d min-altitude= "number" ></gmp-map-3d>
minHeading
Type:numberoptional
The minimum angle of heading (rotation) of the map. A valid value is between0and360degrees.minHeadingandmaxHeadingrepresent an interval of <=360degrees in which heading gestures will be allowed.minHeading = 180andmaxHeading = 90will allow heading in[0, 90]and heading in[180, 360].minHeading = 90andmaxHeading = 180will allow heading in[90, 180].
HTML attribute:
  • <gmp-map-3d min-heading= "number" ></gmp-map-3d>
minTilt
Type:numberoptional
The minimum angle of incidence of the map. A valid value is between0and90degrees.
HTML attribute:
  • <gmp-map-3d min-tilt= "number" ></gmp-map-3d>
range
Type:numberoptional
The distance from camera to the center of the map, in meters.
HTML attribute:
  • <gmp-map-3d range= "number" ></gmp-map-3d>
roll
Type:numberoptional
The roll of the camera around the view vector in degrees. To resolve ambiguities, when there is no tilt, any roll will be interpreted as heading.
HTML attribute:
  • <gmp-map-3d roll= "number" ></gmp-map-3d>
tilt
Type:numberoptional
The tilt of the camera's view vector in degrees. A view vector looking directly down at the earth would have a tilt of zero degrees. A view vector pointing away from the earth would have a tilt of180degrees.
HTML attribute:
  • <gmp-map-3d tilt= "number" ></gmp-map-3d>
BetaaddEventListener
addEventListener(type, listener[, options])
Parameters:
  • type:stringA case-sensitive string representing the event type to listen for.
  • listener:EventListener|EventListenerObjectThe object that receives a notification. This must be a function or an object with the handleEvent method
  • options:boolean|AddEventListenerOptionsoptionalSeeoptions.Custom events only supportcaptureandpassive.
Return Value:void
Sets up a function that will be called whenever the specified event is delivered to the target. SeeaddEventListener
BetaremoveEventListener
removeEventListener(type, listener[, options])
Parameters:
Return Value:void
Removes an event listener previously registered with addEventListener from the target. SeeremoveEventListener
gmp-centerchange
function(centerChangeEvent)
Arguments:
This event is fired when the Map3DElement's center property changes.
gmp-click
function(clickEvent)
Arguments:
This event is fired when theMap3DElementelement is clicked.
gmp-headingchange
function(headingChangeEvent)
Arguments:
This event is fired when the Map3DElement's heading property changes.
gmp-rangechange
function(rangeChangeEvent)
Arguments:
This event is fired when the Map3DElement's range property changes.
gmp-rollchange
function(rollChangeEvent)
Arguments:
This event is fired when the Map3DElement's roll property changes.
gmp-steadychange
function(steadyChangeEvent)
Arguments:
This event is fired when the steady state ofMap3DElementchanges.
gmp-tiltchange
function(tiltChangeEvent)
Arguments:
This event is fired when the Map3DElement's tilt property changes.

Map3DElementOptions interface

google.maps.maps3d.Map3DElementOptions interface

Map3DElementOptions object used to define the properties that can be set on a Map3DElement.

boundsoptional
centeroptional
defaultLabelsDisabledoptional
Type:booleanoptional
headingoptional
Type:numberoptional
maxAltitudeoptional
Type:numberoptional
maxHeadingoptional
Type:numberoptional
maxTiltoptional
Type:numberoptional
minAltitudeoptional
Type:numberoptional
minHeadingoptional
Type:numberoptional
minTiltoptional
Type:numberoptional
rangeoptional
Type:numberoptional
rolloptional
Type:numberoptional
tiltoptional
Type:numberoptional

SteadyChangeEvent class

google.maps.maps3d.SteadyChangeEvent class

This event is created from monitoring a steady state ofMap3DElement.

This class extends Event.

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

isSteady
Type:boolean
Indicates whether Map3DElement is steady (i.e. all rendering for the current scene has completed) or not.

ClickEvent class

google.maps.maps3d.ClickEvent class

This event is created from clicking a Map3DElement.

This class extends Event.

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

position
Type:LatLngAltitudeoptional
The latitude/longitude/altitude that was below the cursor when the event occurred. Please note, that at coarser levels, less accurate data will be returned. Also, sea floor elevation may be returned for the altitude value when clicking at the water surface from higher camera positions.

CenterChangeEvent class

google.maps.maps3d.CenterChangeEvent class

This event is created from monitoring center change onMap3DElement.

This class extends Event.

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

HeadingChangeEvent class

google.maps.maps3d.HeadingChangeEvent class

This event is created from monitoring heading change onMap3DElement.

This class extends Event.

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

RangeChangeEvent class

google.maps.maps3d.RangeChangeEvent class

This event is created from monitoring range change onMap3DElement.

This class extends Event.

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

RollChangeEvent class

google.maps.maps3d.RollChangeEvent class

This event is created from monitoring roll change onMap3DElement.

This class extends Event.

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

TiltChangeEvent class

google.maps.maps3d.TiltChangeEvent class

This event is created from monitoring tilt change onMap3DElement.

This class extends Event.

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

Polyline3DElement class

google.maps.maps3d.Polyline3DElement class

A 3D polyline is a linear overlay of connected line segments on a 3D map.

Custom element:
<gmp-polyline-3d altitude-mode= "absolute" draws-occluded-segments extruded geodesic outer-color= "string" outer-opacity= "number" outer-width= "number" stroke-color= "string" stroke-opacity= "number" stroke-width= "number" z-index= "number" ></gmp-polyline-3d>

This class extends HTMLElement.

This class implements Polyline3DElementOptions.

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

Polyline3DElement
Polyline3DElement([options])
Parameters:
altitudeMode
Type:AltitudeModeoptional
Specifies how altitude components in the coordinates are interpreted.
HTML attribute:
  • <gmp-polyline-3d altitude-mode= "absolute" ></gmp-polyline-3d>
  • <gmp-polyline-3d altitude-mode= "clamp-to-ground" ></gmp-polyline-3d>
  • <gmp-polyline-3d altitude-mode= "relative-to-ground" ></gmp-polyline-3d>
  • <gmp-polyline-3d altitude-mode= "relative-to-mesh" ></gmp-polyline-3d>
coordinates
The ordered sequence of coordinates of the Polyline. Altitude is ignored in certain modes and thus optional.
drawsOccludedSegments
Type:booleanoptional
Default:false
Specifies whether parts of the polyline which could be occluded are drawn or not. Polylines can be occluded by map geometry (e.g. buildings).
HTML attribute:
  • <gmp-polyline-3d draws-occluded-segments></gmp-polyline-3d>
extruded
Type:booleanoptional
Default:false
Specifies whether to connect the polyline to the ground. To extrude a polyline, thealtitudeModemust be eitherRELATIVE_TO_GROUNDorABSOLUTE.
HTML attribute:
  • <gmp-polyline-3d extruded></gmp-polyline-3d>
geodesic
Type:booleanoptional
Default:false
Whentrue,edges of the polyline are interpreted as geodesic and will follow the curvature of the Earth. Whenfalse,edges of the polyline are rendered as straight lines in screen space.
HTML attribute:
  • <gmp-polyline-3d geodesic></gmp-polyline-3d>
outerColor
Type:stringoptional
The outer color. All CSS3 colors are supported except for extended named colors.
HTML attribute:
  • <gmp-polyline-3d outer-color= "string" ></gmp-polyline-3d>
outerOpacity
Type:numberoptional
The outer opacity between0.0and1.0.
HTML attribute:
  • <gmp-polyline-3d outer-opacity= "number" ></gmp-polyline-3d>
outerWidth
Type:numberoptional
The outer width is between0.0and1.0.This is a percentage of thestrokeWidth.
HTML attribute:
  • <gmp-polyline-3d outer-width= "number" ></gmp-polyline-3d>
strokeColor
Type:stringoptional
The stroke color. All CSS3 colors are supported except for extended named colors.
HTML attribute:
  • <gmp-polyline-3d stroke-color= "string" ></gmp-polyline-3d>
strokeOpacity
Type:numberoptional
The stroke opacity between0.0and1.0.
HTML attribute:
  • <gmp-polyline-3d stroke-opacity= "number" ></gmp-polyline-3d>
strokeWidth
Type:numberoptional
The stroke width in pixels.
HTML attribute:
  • <gmp-polyline-3d stroke-width= "number" ></gmp-polyline-3d>
zIndex
Type:numberoptional
The zIndex compared to other polys.
HTML attribute:
  • <gmp-polyline-3d z-index= "number" ></gmp-polyline-3d>
BetaaddEventListener
addEventListener(type, listener[, options])
Parameters:
  • type:stringA case-sensitive string representing the event type to listen for.
  • listener:EventListener|EventListenerObjectThe object that receives a notification. This must be a function or an object with the handleEvent method
  • options:boolean|AddEventListenerOptionsoptionalSeeoptions.Custom events only supportcaptureandpassive.
Return Value:void
Sets up a function that will be called whenever the specified event is delivered to the target. SeeaddEventListener
BetaremoveEventListener
removeEventListener(type, listener[, options])
Parameters:
Return Value:void
Removes an event listener previously registered with addEventListener from the target. SeeremoveEventListener

Polyline3DElementOptions interface

google.maps.maps3d.Polyline3DElementOptions interface

Polyline3DElementOptions object used to define the properties that can be set on a Polyline3DElement.

altitudeModeoptional
Type:AltitudeModeoptional
coordinatesoptional
drawsOccludedSegmentsoptional
Type:booleanoptional
Default:false
extrudedoptional
Type:booleanoptional
Default:false
geodesicoptional
Type:booleanoptional
Default:false
outerColoroptional
Type:stringoptional
outerOpacityoptional
Type:numberoptional
outerWidthoptional
Type:numberoptional
strokeColoroptional
Type:stringoptional
strokeOpacityoptional
Type:numberoptional
strokeWidthoptional
Type:numberoptional
zIndexoptional
Type:numberoptional

Polygon3DElement class

google.maps.maps3d.Polygon3DElement class

A 3D polygon (like a 3D polyline) defines a series of connected coordinates in an ordered sequence. Additionally, polygons form a closed loop and define a filled region.

Custom element:
<gmp-polygon-3d altitude-mode= "absolute" draws-occluded-segments extruded fill-color= "string" fill-opacity= "number" geodesic stroke-color= "string" stroke-opacity= "number" stroke-width= "number" z-index= "number" ></gmp-polygon-3d>

This class extends HTMLElement.

This class implements Polygon3DElementOptions.

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

Polygon3DElement
Polygon3DElement([options])
Parameters:
altitudeMode
Type:AltitudeModeoptional
Specifies how altitude components in the coordinates are interpreted.
HTML attribute:
  • <gmp-polygon-3d altitude-mode= "absolute" ></gmp-polygon-3d>
  • <gmp-polygon-3d altitude-mode= "clamp-to-ground" ></gmp-polygon-3d>
  • <gmp-polygon-3d altitude-mode= "relative-to-ground" ></gmp-polygon-3d>
  • <gmp-polygon-3d altitude-mode= "relative-to-mesh" ></gmp-polygon-3d>
drawsOccludedSegments
Type:booleanoptional
Default:false
Specifies whether parts of the polygon which could be occluded are drawn or not. Polygons can be occluded by map geometry (e.g. buildings).
HTML attribute:
  • <gmp-polygon-3d draws-occluded-segments></gmp-polygon-3d>
extruded
Type:booleanoptional
Default:false
Specifies whether to connect the polygon to the ground. To extrude a polygon, thealtitudeModemust be eitherRELATIVE_TO_GROUNDorABSOLUTE.
HTML attribute:
  • <gmp-polygon-3d extruded></gmp-polygon-3d>
fillColor
Type:stringoptional
The fill color. All CSS3 colors are supported except for extended named colors.
HTML attribute:
  • <gmp-polygon-3d fill-color= "string" ></gmp-polygon-3d>
fillOpacity
Type:numberoptional
The fill opacity between 0.0 and 1.0.
HTML attribute:
  • <gmp-polygon-3d fill-opacity= "number" ></gmp-polygon-3d>
geodesic
Type:booleanoptional
Default:false
Whentrue,edges of the polygon are interpreted as geodesic and will follow the curvature of the Earth. Whenfalse,edges of the polygon are rendered as straight lines in screen space.
HTML attribute:
  • <gmp-polygon-3d geodesic></gmp-polygon-3d>
innerCoordinates
The ordered sequence of coordinates that designates a closed loop. Unlike polylines, a polygon may consist of one or more paths, which create multiple cut-outs inside the polygon.
outerCoordinates
The ordered sequence of coordinates that designates a closed loop. Altitude is ignored in certain modes and thus optional.
strokeColor
Type:stringoptional
The stroke color. All CSS3 colors are supported except for extended named colors.
HTML attribute:
  • <gmp-polygon-3d stroke-color= "string" ></gmp-polygon-3d>
strokeOpacity
Type:numberoptional
The stroke opacity between0.0and1.0.
HTML attribute:
  • <gmp-polygon-3d stroke-opacity= "number" ></gmp-polygon-3d>
strokeWidth
Type:numberoptional
The stroke width in pixels.
HTML attribute:
  • <gmp-polygon-3d stroke-width= "number" ></gmp-polygon-3d>
zIndex
Type:numberoptional
The zIndex compared to other polys.
HTML attribute:
  • <gmp-polygon-3d z-index= "number" ></gmp-polygon-3d>
BetaaddEventListener
addEventListener(type, listener[, options])
Parameters:
  • type:stringA case-sensitive string representing the event type to listen for.
  • listener:EventListener|EventListenerObjectThe object that receives a notification. This must be a function or an object with the handleEvent method
  • options:boolean|AddEventListenerOptionsoptionalSeeoptions.Custom events only supportcaptureandpassive.
Return Value:void
Sets up a function that will be called whenever the specified event is delivered to the target. SeeaddEventListener
BetaremoveEventListener
removeEventListener(type, listener[, options])
Parameters:
Return Value:void
Removes an event listener previously registered with addEventListener from the target. SeeremoveEventListener

Polygon3DElementOptions interface

google.maps.maps3d.Polygon3DElementOptions interface

Polygon3DElementOptions object used to define the properties that can be set on a Polygon3DElement.

altitudeModeoptional
Type:AltitudeModeoptional
drawsOccludedSegmentsoptional
Type:booleanoptional
Default:false
extrudedoptional
Type:booleanoptional
Default:false
fillColoroptional
Type:stringoptional
fillOpacityoptional
Type:numberoptional
geodesicoptional
Type:booleanoptional
Default:false
innerCoordinatesoptional
outerCoordinatesoptional
strokeColoroptional
Type:stringoptional
strokeOpacityoptional
Type:numberoptional
strokeWidthoptional
Type:numberoptional
zIndexoptional
Type:numberoptional

AltitudeMode constants

google.maps.maps3d.AltitudeMode constants

Specifies how altitude components in the coordinates are interpreted.

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

ABSOLUTE Allows to express objects relative to the average mean sea level. That also means that if the terrain level of detail changes underneath the object, its absolute position will remain the same.
CLAMP_TO_GROUND Allows to express objects placed on the ground. They will remain at ground level following the terrain regardless of what altitude is provided. If the object is positioned over a major body of water, it will be placed at sea level.
RELATIVE_TO_GROUND Allows to express objects relative to the ground surface. If the terrain level of detail changes, the position of the object will remain constant relative to the ground. When over water, the altitude will be interpreted as a value in meters above sea level.
RELATIVE_TO_MESH Allows to express objects relative to the highest of ground+building+water surface. When over water, this will be water surface; when over terrain, this will be the building surface (if present) or ground surface (if no buildings).