Options
All
  • Public
  • Public/Protected
  • All
Menu

You can implement this class if you want to display custom types of overlay objects on the map.

Inherit from this class by setting your overlay's prototype: MyOverlay.prototype = new google.maps.OverlayView();. The OverlayView constructor is guaranteed to be an empty function.

You must implement three methods: onAdd(), draw(), and onRemove().

  • In the onAdd() method, you should create DOM objects and append them as children of the panes.
  • In the draw() method, you should position these elements.
  • In the onRemove() method, you should remove the objects from the DOM.
You must call 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 draw() 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.

Access by calling const {OverlayView} = await google.maps.importLibrary("maps") or const {OverlayView} = await google.maps.importLibrary("streetView"). 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

  • draw(): void
  • Implement this method to draw or update the overlay. Use the position from projection.fromLatLngToDivPixel() to correctly position the overlay relative to the MapPanes. This method is called after onAdd(), and is called on change of zoom or center. It is not recommended to do computationally expensive work in this method.

    Returns void

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

    Parameters

    • key: string

    Returns any

  • Returns the panes in which this OverlayView can be rendered. The panes are not initialized until onAdd is called by the API.

    Returns null | MapPanes

  • Returns the MapCanvasProjection object associated with this OverlayView. The projection is not initialized until onAdd is called by the API.

    Returns MapCanvasProjection

  • 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 initialize the overlay DOM elements. This method is called once after setMap() is called with a valid map. At this point, panes and projection will have been initialized.

    Returns void

  • onRemove(): void
  • Implement this method to remove your elements from the DOM. This method is called once following a call to setMap(null).

    Returns void

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

    Parameters

    • key: string
    • value: unknown

    Returns void

  • Adds the overlay to the map or panorama.

    Parameters

    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
  • preventMapHitsAndGesturesFrom(this: any, element: Element): void
  • Stops click, tap, drag, and wheel events on the element from bubbling up to the map. Use this to prevent map dragging and zooming, as well as map "click" events.

    Parameters

    • this: any
    • element: Element

    Returns void

  • preventMapHitsFrom(this: any, element: Element): void
  • Stops click or tap on the element from bubbling up to the map. Use this to prevent the map from triggering "click" events.

    Parameters

    • this: any
    • element: Element

    Returns void

Generated using TypeDoc