WebGLOverlayView class
google.maps
. WebGLOverlayView
class
The WebGL Overlay View provides direct access to the same WebGL rendering context Google Maps Platform uses to render the vector basemap. This use of a shared rendering context provides benefits such as depth occlusion with 3D building geometry, and the ability to sync 2D/3D content with basemap rendering.
With WebGL Overlay View you can add content to your maps using WebGL directly, or popular Graphics libraries like Three.js or deck.gl. To use the overlay, you can extend google.maps.WebGLOverlayView
and provide an implementation for each of the following lifecycle hooks: WebGLOverlayView.onAdd
, WebGLOverlayView.onContextRestored
, WebGLOverlayView.onDraw
, WebGLOverlayView.onContextLost
and WebGLOverlayView.onRemove
.
You must call WebGLOverlayView.setMap
with a valid Map
object to trigger the call to the onAdd()
method and setMap(null)
in order to trigger the onRemove()
method. The setMap()
method can be called at the time of construction or at any point afterward when the overlay should be re-shown after removing. The onDraw()
method will then be called whenever a map property changes that could change the position of the element, such as zoom, center, or map type. WebGLOverlayView may only be added to a vector map having a MapOptions.mapId
(including maps set to the RenderingType.VECTOR
MapOptions.renderingType
and using Map.DEMO_MAP_ID
as the MapOptions.mapId
).
This class extends MVCObject
.
Access by calling const {WebGLOverlayView} = await google.maps.importLibrary("maps")
.See Libraries in the Maps JavaScript API
.
Constructor |
|
---|---|
WebGLOverlayView
|
WebGLOverlayView()
Parameters: None
Creates a
WebGLOverlayView
. |
Methods
onAdd()
onContextLost()
onContextRestored(options)
-
options
:WebGLStateOptions
that allow developers to restore the GL context.
onDraw(options)
-
options
:WebGLDrawOptions
that allow developers to render content to an associated Google basemap.
WebGLOverlayView.requestRedraw
.onRemove()
WebGLOverlayView.setMap(null)
, and is where you should remove all intermediate objects. This method must be implemented to render.onStateUpdate(options)
-
options
:WebGLStateOptions
that allow developerse to restore the GL context.
requestRedraw()
requestStateUpdate()
WebGLDrawOptions interface
google.maps
. WebGLDrawOptions
interface
Drawing options.
Properties |
|
---|---|
gl
|
Type:
WebGLRenderingContext
The WebGLRenderingContext on which to render this WebGLOverlayView.
|
transformer
|
Type:
CoordinateTransformer
The matrix transformation from camera space to latitude/longitude coordinates.
|
WebGLStateOptions interface
google.maps
. WebGLStateOptions
interface
GL state options.
Properties |
|
---|---|
gl
|
Type:
WebGLRenderingContext
The WebGLRenderingContext on which to render this WebGLOverlayView.
|
CoordinateTransformer interface
google.maps
. CoordinateTransformer
interface
This interface provides convenience methods for generating matrices to use for rendering WebGL scenes on top of the Google base map.
Note: A reference to this object should not
be held outside of the scope of the encapsulating WebGLOverlayView.onDraw
call.
Methods
fromLatLngAltitude(latLngAltitude[, rotations, scale])
-
latLngAltitude
:LatLngAltitude | LatLngAltitudeLiteral
Latitude, longitude, and altitude. -
rotations
:Float32Array optional
An array that contains an Euler rotation angle in degrees, in the XYZ convention. -
scale
:Float32Array optional
Array that contains an XYZ scalar array to apply to the cardinal axis.
Float64Array
MVP matrix to use with WebGL.CameraParams interface
google.maps
. CameraParams
interface
Used for retrieving camera parameters, such as that of the GL camera used for the WebGLOverlayView
.
This interface extends CameraOptions
.
Properties |
|
---|---|
center
|
Type:
LatLng
|
heading
|
Type:
number
|
tilt
|
Type:
number
|
zoom
|
Type:
number
|