Options
All
  • Public
  • Public/Protected
  • All
Menu

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: google.maps.WebGLOverlayView.onAdd, google.maps.WebGLOverlayView.onContextRestored, google.maps.WebGLOverlayView.onDraw, google.maps.WebGLOverlayView.onContextLost and google.maps.WebGLOverlayView.onRemove.

You must call google.maps.WebGLOverlayView.setMap with a valid google.maps.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 google.maps.MapOptions.mapId.

Access by calling const {WebGLOverlayView} = await google.maps.importLibrary("maps"). See https://developers.google.com/maps/documentation/javascript/libraries.

Hierarchy

Index

Constructors

Methods

  • Adds the given listener function to the given event name. Returns an identifier for this listener that can be used with google.maps.event.removeListener.

    Parameters

    • eventName: string
    • handler: Function

    Returns MapsEventListener

  • bindTo(key: string, target: MVCObject, targetKey?: null | string, noNotify?: boolean): void
  • Binds a View to a Model.

    Parameters

    • key: string
    • target: MVCObject
    • Optional targetKey: null | string
    • Optional noNotify: boolean

    Returns void

  • get(key: string): any
  • Gets a value.

    Parameters

    • key: string

    Returns any

  • getMap(): undefined | null | Map
  • Returns undefined | null | Map

  • notify(key: string): void
  • Notify all observers of a change on this property. This notifies both objects that are bound to the object's property as well as the object that it is bound to.

    Parameters

    • key: string

    Returns void

  • onAdd(): void
  • Implement this method to fetch or create intermediate data structures before the overlay is drawn that don’t require immediate access to the WebGL rendering context. This method must be implemented to render.

    Returns void

  • onContextLost(): void
  • This method is called when the rendering context is lost for any reason, and is where you should clean up any pre-existing GL state, since it is no longer needed.

    Returns void

  • This method is called once the rendering context is available. Use it to initialize or bind any WebGL state such as shaders or buffer objects.

    Parameters

    Returns void

  • Implement this method to draw WebGL content directly on the map. Note that if the overlay needs a new frame drawn then call google.maps.WebGLOverlayView.requestRedraw.

    Parameters

    • options: WebGLDrawOptions

      that allow developers to render content to an associated Google basemap.

    Returns void

  • onRemove(): void
  • This method is called when the overlay is removed from the map with WebGLOverlayView.setMap(null), and is where you should remove all intermediate objects. This method must be implemented to render.

    Returns void

  • Implement this method to handle any GL state updates outside of the render animation frame.

    Parameters

    Returns void

  • requestRedraw(): void
  • Triggers the map to redraw a frame.

    Returns void

  • requestStateUpdate(): void
  • Triggers the map to update GL state.

    Returns void

  • set(key: string, value: unknown): void
  • Sets a value.

    Parameters

    • key: string
    • value: unknown

    Returns void

  • setMap(map?: null | Map): void
  • Adds the overlay to the map.

    Parameters

    • Optional map: null | Map

      The map to access the div, model and view state.

    Returns void

  • setValues(values?: null | object): void
  • Sets a collection of key-value pairs.

    Parameters

    • Optional values: null | object

    Returns void

  • unbind(key: string): void
  • Removes a binding. Unbinding will set the unbound property to the current value. The object will not be notified, as the value has not changed.

    Parameters

    • key: string

    Returns void

  • unbindAll(): void

Generated using TypeDoc