Map3DElement class
google.maps.maps3d
. Map3DElement
class
extends HTMLElement
implements Map3DElementOptions
Map3DElement is an HTML interface for the 3D Map view. Note that the mode
must be set for the 3D Map to start rendering.
<gmp-map-3d autofits-camera-animation=" value-name " camera-position=" lat,lng,altitude " center=" lat,lng,altitude " default-ui-hidden description=" string " fov=" number " gesture-handling=" value-name " heading=" number " internal-usage-attribution-ids=" id1 id2 " map-id=" string " max-altitude=" number " max-heading=" number " max-tilt=" number " min-altitude=" number " min-heading=" number " min-tilt=" number " mode=" value-name " range=" number " roll=" number " tilt=" number "> </gmp-map-3d>
const { Map3DElement } = await google . maps . importLibrary ( "maps3d" );
Constructor
Map3DElement([options])
-
options:Map3DElementOptions optional
Properties |
|
|---|---|
|
Type:
AutofitsCameraAnimation
optional
Default:
none
The animation to use for automatic camera fitting.
HTML attribute:
autofits-camera-animation="value-name"
|
bounds
|
Type:
LatLngBounds
| LatLngBoundsLiteral
optional
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
-180
and 180
, respectively. For longitude-only bounds use north and south latitudes of 90
and -90
, respectively. |
cameraPosition
|
Type:
LatLngAltitude
| LatLngAltitudeLiteral
optional
The position of the camera given as a LatLngAltitude. Will be derived if omitted. If
center
is omitted but cameraPosition
is specified, center
will derive from cameraPosition.
If both are updated in the same run loop, cameraPosition
will be favored. The fields cameraPosition
and center
can be one-to-one-derived from each other in context of the given shared heading, range, roll, and tilt. HTML attribute:
camera-position="lat,lng,altitude"
|
center
|
Type:
LatLngAltitude
| LatLngAltitudeLiteral
optional
The center of the map given as a LatLngAltitude, where altitude is in meters above the mean sea level. Note that this is not necessarily where the camera is located, as the
range
field 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:
center="lat,lng,altitude"
|
defaultUIHidden
|
Type:
boolean optional
Default:
false
When
true
, all default UI buttons are hidden. HTML attribute:
default-ui-hidden
|
description
|
Type:
string optional
If provided, an accessibility description (e.g. for use with screen readers) will be added to the map with the provided value.
HTML attribute:
description="string"
|
fov
|
Type:
number optional
Specifies the vertical field of view in degrees. Valid values range from 5.0 to 80.0. Higher values increase the visible area but may introduce perspective distortion. Default: 35.0.
HTML attribute:
fov="number"
|
gestureHandling
|
Type:
GestureHandling
optional
Default:
GestureHandling.GREEDY
Controls cooperative gesture handling. When set to
COOPERATIVE
, modifier keys or two-finger gestures are required to scroll the map. When set to GREEDY
, the host page cannot be scrolled from user events on the map element. When set to AUTO
, the gesture handling is determined by the scrollability of the host page. HTML attribute:
gesture-handling="value-name"
|
heading
|
Type:
number optional
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:
heading="number"
|
internalUsageAttributionIds
|
Type:
Iterable
<string> optional
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. Only unique values will be sent. Changes to this value after instantiation may be ignored.
HTML attribute:
internal-usage-attribution-ids="id1 id2"
|
language
|
Type:
string optional
Language in which to attempt to render the base map's language. Will default to the language requested by the developer when loading the Maps JS API.
|
mapId
|
Type:
string optional
Specifies a map ID which will be used to fetch cloud-based map style for the map.
HTML attribute:
map-id="string"
|
maxAltitude
|
Type:
number optional
The maximum altitude above the ground which will be displayed on the map. A valid value is between
0
and 63170000
meters (Earth radius multiplied by 10). HTML attribute:
max-altitude="number"
|
maxHeading
|
Type:
number optional
The maximum angle of heading (rotation) of the map. A valid value is between
0
and 360
degrees. minHeading
and maxHeading
represent an interval of <= 360
degrees in which heading gestures will be allowed. minHeading = 180
and maxHeading = 90
will allow heading in [0, 90]
and heading in [180, 360]
. minHeading = 90
and maxHeading = 180
will allow heading in [90, 180]
. HTML attribute:
max-heading="number"
|
maxTilt
|
Type:
number optional
The maximum angle of incidence of the map. A valid value is between
0
and 90
degrees. HTML attribute:
max-tilt="number"
|
minAltitude
|
Type:
number optional
The minimum altitude above the ground which will be displayed on the map. A valid value is between
0
and 63170000
meters (Earth radius multiplied by 10). HTML attribute:
min-altitude="number"
|
minHeading
|
Type:
number optional
The minimum angle of heading (rotation) of the map. A valid value is between
0
and 360
degrees. minHeading
and maxHeading
represent an interval of <= 360
degrees in which heading gestures will be allowed. minHeading = 180
and maxHeading = 90
will allow heading in [0, 90]
and heading in [180, 360]
. minHeading = 90
and maxHeading = 180
will allow heading in [90, 180]
. HTML attribute:
min-heading="number"
|
minTilt
|
Type:
number optional
The minimum angle of incidence of the map. A valid value is between
0
and 90
degrees. HTML attribute:
min-tilt="number"
|
mode
|
Type:
MapMode
optional
Specifies a mode the map should be rendered in. If not set, the map won't be rendered.
HTML attribute:
mode="value-name"
|
range
|
Type:
number optional
The distance from camera to the center of the map, in meters.
HTML attribute:
range="number"
|
region
|
Type:
string optional
Region with which to attempt to render the base map's POIs. Will default to the region requested by the developer when loading the Maps JS API.
|
roll
|
Type:
number optional
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:
roll="number"
|
tilt
|
Type:
number optional
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 of
180
degrees. HTML attribute:
tilt="number"
|
|
Type:
boolean optional
Default:
false
When
true
, all default UI buttons are disabled. Does not disable the keyboard and gesture controls. HTML attribute:
default-ui-disabled
|
Methods
flyCameraAround(options)
-
options:FlyAroundAnimationOptions
FlyAroundAnimationOptions.repeatCount
times.The camera will move in a clockwise direction.
The location being orbited around is specified via
CameraOptions.center
. This is the location that will show in the center of the viewport during the orbit animation, while the camera moves around it.The method is asynchronous because animations can only start after the map has loaded a minimum amount. The method returns once the animation has been started.
If the number of
FlyAroundAnimationOptions.repeatCount
times is zero, no spin will occur, and the animation will complete immediately after it starts.flyCameraTo(options)
-
options:FlyToAnimationOptions
CameraOptions.cameraPosition
, which controls the exact camera position, or via CameraOptions.center
, which controls the visible viewport center of the map.The method is asynchronous because animations can only start after the map has loaded a minimum amount. The method returns once the animation has been started.
stopCameraAnimation()
The method is asynchronous because animations can only start or stop after the map has loaded a minimum amount. The method returns once the animation has stopped.
Events
function(animationEndEvent)
-
animationEndEvent:Event optional
function(cameraPositionChangeEvent)
-
cameraPositionChangeEvent:Event optional
function(centerChangeEvent)
-
centerChangeEvent:Event optional
function(clickEvent)
-
clickEvent:LocationClickEvent | PlaceClickEvent optional
function(mapInitializationErrorEvent)
-
mapInitializationErrorEvent:Event optional
function(fovChangeEvent)
-
fovChangeEvent:Event optional
function(headingChangeEvent)
-
headingChangeEvent:Event optional
function(mapIdErrorEvent)
-
mapIdErrorEvent:Event optional
function(rangeChangeEvent)
-
rangeChangeEvent:Event optional
function(rollChangeEvent)
-
rollChangeEvent:Event optional
function(steadyChangeEvent)
-
steadyChangeEvent:SteadyChangeEvent optional
Map3DElement
changes.function(tiltChangeEvent)
-
tiltChangeEvent:Event optional
Map3DElementOptions interface
google.maps.maps3d
. Map3DElementOptions
interface
Map3DElementOptions object used to define the properties that can be set on a Map3DElement.
Properties |
|
|---|---|
|
Type:
AutofitsCameraAnimation
optional
|
bounds
optional
|
Type:
LatLngBounds
| LatLngBoundsLiteral
optional
|
cameraPosition
optional
|
Type:
LatLngAltitude
| LatLngAltitudeLiteral
optional
|
center
optional
|
Type:
LatLngAltitude
| LatLngAltitudeLiteral
optional
|
|
Type:
boolean optional
|
defaultUIHidden
optional
|
Type:
boolean optional
|
description
optional
|
Type:
string optional
|
fov
optional
|
Type:
number optional
|
gestureHandling
optional
|
Type:
GestureHandling
optional
|
heading
optional
|
Type:
number optional
|
internalUsageAttributionIds
optional
|
Type:
Iterable
<string> optional
|
language
optional
|
Type:
string optional
|
mapId
optional
|
Type:
string optional
|
maxAltitude
optional
|
Type:
number optional
|
maxHeading
optional
|
Type:
number optional
|
maxTilt
optional
|
Type:
number optional
|
minAltitude
optional
|
Type:
number optional
|
minHeading
optional
|
Type:
number optional
|
minTilt
optional
|
Type:
number optional
|
mode
optional
|
Type:
MapMode
optional
|
range
optional
|
Type:
number optional
|
region
optional
|
Type:
string optional
|
roll
optional
|
Type:
number optional
|
tilt
optional
|
Type:
number optional
|
MapMode constants
google.maps.maps3d
. MapMode
constants
Specifies a mode the map should be rendered in.
const { MapMode } = await google . maps . importLibrary ( "maps3d" );
Constants |
|
|---|---|
HYBRID
|
This map mode displays a transparent layer of major streets on satellite, or photorealistic imagery. |
|
This map mode displays a normal street map. |
SATELLITE
|
This map mode displays satellite, or photorealistic imagery where available. |
GestureHandling constants
google.maps.maps3d
. GestureHandling
constants
Specifies how gesture events should be handled on the map element.
const { GestureHandling } = await google . maps . importLibrary ( "maps3d" );
Constants |
|
|---|---|
AUTO
|
This lets the map choose whether to use cooperative or greedy gesture handling. This is the default behavior if not specified. This will cause the map to enter cooperative mode if the map is dominating its scroll parent (usually the host page) to where the user cannot scroll away from the map to other content. |
COOPERATIVE
|
This forces cooperative mode, where modifier keys or two-finger gestures are required to scroll the map. |
GREEDY
|
This forces greedy mode, where the host page cannot be scrolled from user events on the map element. |
AutofitsCameraAnimation constants
google.maps.maps3d
. AutofitsCameraAnimation
constants
Specifies how the camera should behave when it moves to a new position to center itself according to its opted-in child elements.
const { AutofitsCameraAnimation } = await google . maps . importLibrary ( "maps3d" );
Constants |
|
|---|---|
FLY_TO
|
Flies to the new position. |
NONE
|
Snaps to the new position without an animation. |
FlyAroundAnimationOptions interface
google.maps.maps3d
. FlyAroundAnimationOptions
interface
Customization options for the FlyCameraAround Animation.
Properties |
|
|---|---|
camera
|
Type:
CameraOptions
The central point at which the camera should look at during the orbit animation. Note that the map heading will change as the camera orbits around this center point.
|
durationMillis
optional
|
Type:
number optional
The duration of one animation cycle in milliseconds.
|
repeatCount
optional
|
Type:
number optional
Specifies the number of times an animation should repeat. If the number is zero, the animation will complete immediately after it starts. If Number.Infinity is passed, the animation will repeat forever.
|
|
Type:
number optional
The number of rounds to rotate around the center in the given duration. This controls the overall speed of rotation. Passing a negative number to rounds will cause the camera to rotate in a counter-clockwise direction instead of the default clockwise direction.
|
FlyToAnimationOptions interface
google.maps.maps3d
. FlyToAnimationOptions
interface
Customization options for the FlyCameraTo Animation.
Properties |
|
|---|---|
endCamera
|
Type:
CameraOptions
The location at which the camera should point at the end of the animation.
|
durationMillis
optional
|
Type:
number optional
The duration of the animation in milliseconds. A duration of 0 will teleport the camera straight to the end position.
|
CameraOptions interface
google.maps.maps3d
. CameraOptions
interface
CameraOptions object used to define the properties that can be set on a camera object. The camera object can be anything that has a camera position, e.g. a current map state, or a future requested animation state.
Properties |
|
|---|---|
altitudeMode
optional
|
Type:
AltitudeMode
optional
Default:
AltitudeMode.ABSOLUTE
An enum specifying how to interpret the altitude value of the given
CameraOptions
object. This reuses the existing AltitudeMode
enum. |
cameraPosition
optional
|
Type:
LatLngAltitude
| LatLngAltitudeLiteral
optional
|
center
optional
|
Type:
LatLngAltitude
| LatLngAltitudeLiteral
optional
|
fov
optional
|
Type:
number optional
|
heading
optional
|
Type:
number optional
|
range
optional
|
Type:
number optional
|
roll
optional
|
Type:
number optional
|
tilt
optional
|
Type:
number optional
|
SteadyChangeEvent class
google.maps.maps3d
. SteadyChangeEvent
class
extends Event
This event is created from monitoring a steady state of Map3DElement
. This event bubbles up through the DOM tree.
const { SteadyChangeEvent } = await google . maps . importLibrary ( "maps3d" );
Properties |
|
|---|---|
isSteady
|
Type:
boolean
Indicates whether Map3DElement is steady (i.e. all rendering for the current scene has completed) or not.
|
LocationClickEvent class
google.maps.maps3d
. LocationClickEvent
class
extends Event
This event is created from clicking a Map3DElement.
const { LocationClickEvent } = await google . maps . importLibrary ( "maps3d" );
Properties |
|
|---|---|
position
|
Type:
LatLngAltitude
optional
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. This event bubbles up through the DOM tree.
|
PlaceClickEvent class
google.maps.maps3d
. PlaceClickEvent
class
extends LocationClickEvent
This event is created from clicking on a place icon on a Map3DElement
. To prevent the default popover from showing up, call the preventDefault()
method on this event to prevent it being handled by the Map3DElement
.
const { PlaceClickEvent } = await google . maps . importLibrary ( "maps3d" );
Properties |
|
|---|---|
placeId
|
Type:
string
The place id of the map feature.
|
Inherited:
position
|
|
Methods |
|
|---|---|
fetchPlace
|
fetchPlace()
Parameters: None
Fetches a
Place
for this place id. In the resulting Place
object, the id property will be populated. Additional fields can be subsequently requested via Place.fetchFields()
subject to normal Places API enablement and billing. The promise is rejected if there was an error fetching the Place
. |

