3D Maps
Map3DElement class
google.maps.maps3d.Map3DElement
class
Map3DElement is an HTML interface for the 3D Map view. Note that the mode must be set for the 3D Map to start rendering.
Custom element:
<gmp-map-3d camera-position="lat,lng,altitude" center="lat,lng,altitude" default-ui-hidden description="string" fov="number" gesture-handling="auto" 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="hybrid" range="number" roll="number" tilt="number" default-ui-disabled></gmp-map-3d>
This class extends
HTMLElement.
This class implements
Map3DElementOptions.
Access by calling const {Map3DElement} = await google.maps.importLibrary("maps3d").
See Libraries in the Maps JavaScript API.
Constructor | |
|---|---|
Map3DElement |
Parameters:
|
Properties | |
|---|---|
bounds |
Type: 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 |
|
Type: The position of the camera given as a LatLngAltitude. Will be derived if omitted. If HTML attribute:
|
center |
Type: 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 the HTML attribute:
|
defaultUIHidden |
Type: Default: When HTML attribute:
|
description |
Type: If provided, an accessibility description (e.g. for use with screen readers) will be added to the map with the provided value. HTML attribute:
|
|
Type: 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:
|
gestureHandling |
Type: Default: Controls cooperative gesture handling. When set to HTML attribute:
|
heading |
Type: 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:
|
internalUsageAttributionIds |
Type: 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:
|
language |
Type: 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: Specifies a map ID which will be used to fetch cloud-based map style for the map. This should not be set after the map has been initialized. Therefore we ensure the mapId is only set during initialization and do not publish this attribute to public-facing channels. HTML attribute:
|
maxAltitude |
Type: The maximum altitude above the ground which will be displayed on the map. A valid value is between HTML attribute:
|
maxHeading |
Type: The maximum angle of heading (rotation) of the map. A valid value is between HTML attribute:
|
maxTilt |
Type: The maximum angle of incidence of the map. A valid value is between HTML attribute:
|
minAltitude |
Type: The minimum altitude above the ground which will be displayed on the map. A valid value is between HTML attribute:
|
minHeading |
Type: The minimum angle of heading (rotation) of the map. A valid value is between HTML attribute:
|
minTilt |
Type: The minimum angle of incidence of the map. A valid value is between HTML attribute:
|
mode |
Type: Specifies a mode the map should be rendered in. If not set, the map won't be rendered. HTML attribute:
|
range |
Type: The distance from camera to the center of the map, in meters. HTML attribute:
|
region |
Type: 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: 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:
|
tilt |
Type: 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 HTML attribute:
|
|
Type: Default: When HTML attribute:
|
Methods | |
|---|---|
addEventListener |
Parameters:
Return Value: Sets up a function that will be called whenever the specified event is delivered to the target. See addEventListener. |
flyCameraAround |
Parameters:
Return Value: None This method orbits the camera around a given location for a given duration. The animation can be repeated by the given number of The camera will move in a clockwise direction. The location being orbited around is specified via 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 |
flyCameraTo |
Parameters:
Return Value: None This method moves the camera parabolically from the current location to a given end location over a given duration. End location can be specified via 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. |
removeEventListener |
Parameters:
Return Value: Removes an event listener previously registered with addEventListener from the target. See removeEventListener. |
stopCameraAnimation |
Parameters: None Return Value: None This method stops any fly animation that might happen to be running. The camera stays wherever it is mid-animation; it does not teleport to the end point. 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 | |
|---|---|
gmp-animationend |
Arguments:
This event is fired when the fly animation ends. This event bubbles up through the DOM tree. |
|
Arguments:
This event is fired when the Map3DElement's cameraPosition property changes. |
gmp-centerchange |
Arguments:
This event is fired when the Map3DElement's center property changes. |
gmp-click |
Arguments:
This event is fired when the |
gmp-error |
Arguments:
This event is fired when the map fails to initialize. |
|
Arguments:
This event is fired when the Map3DElement's fov property changes. |
gmp-headingchange |
Arguments:
This event is fired when the Map3DElement's heading property changes. |
gmp-map-id-error |
Arguments:
This event is fired when the Map3DElement's mapId property is invalid. |
gmp-rangechange |
Arguments:
This event is fired when the Map3DElement's range property changes. |
gmp-rollchange |
Arguments:
This event is fired when the Map3DElement's roll property changes. |
gmp-steadychange |
Arguments:
This event is fired when the steady state of |
gmp-tiltchange |
Arguments:
This event is fired when the Map3DElement's tilt property changes. |
MapMode constants
google.maps.maps3d.MapMode
constants
Specifies a mode the map should be rendered in.
Access by calling const {MapMode} = await google.maps.importLibrary("maps3d").
See Libraries in the Maps JavaScript API.
Constants | |
|---|---|
HYBRID |
This map mode displays a transparent layer of major streets on satellite, or photorealistic imagery. |
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.
Access by calling const {GestureHandling} = await google.maps.importLibrary("maps3d").
See Libraries in the Maps JavaScript API.
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. |
FlyAroundAnimationOptions interface
google.maps.maps3d.FlyAroundAnimationOptions
interface
Customization options for the FlyCameraAround Animation.
Properties | |
|---|---|
camera |
Type: 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: The duration of one animation cycle in milliseconds. |
repeatCount optional |
Type: Specifies the number of times an animation should repeat. If the number is zero, the animation will complete immediately after it starts. |
|
Type: 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: The location at which the camera should point at the end of the animation. |
durationMillis optional |
Type: The duration of the animation in milliseconds. A duration of 0 will teleport the camera straight to the end position. |
SteadyChangeEvent class
google.maps.maps3d.SteadyChangeEvent
class
This event is created from monitoring a steady state of Map3DElement. This event bubbles up through the DOM tree.
This class extends
Event.
Access by calling const {SteadyChangeEvent} = await google.maps.importLibrary("maps3d").
See Libraries in the Maps JavaScript API.
Properties | |
|---|---|
isSteady |
Type: Indicates whether Map3DElement is steady (i.e. all rendering for the current scene has completed) or not. |
LocationClickEvent class
google.maps.maps3d.LocationClickEvent
class
This event is created from clicking a Map3DElement.
This class extends
Event.
Access by calling const {LocationClickEvent} = await google.maps.importLibrary("maps3d").
See Libraries in the Maps JavaScript API.
Properties | |
|---|---|
position |
Type: 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
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.
This class extends
LocationClickEvent.
Access by calling const {PlaceClickEvent} = await google.maps.importLibrary("maps3d").
See Libraries in the Maps JavaScript API.
Properties | |
|---|---|
placeId |
Type: The place id of the map feature. |
Inherited:
position
| |
Methods | |
|---|---|
fetchPlace |
Parameters: None Fetches a |