An element to be displayed over the map and attached to a single map location. Like module:ol/control/Control~Control, Overlays are visible widgets. Unlike Controls, they are not in a fixed position on the screen, but are tied to a geographical coordinate, so panning the map will move an Overlay but not a Control.

Example:

import Overlay from 'ol/Overlay.js';

// ...
const popup = new Overlay({
  element: document.getElementById('popup'),
});
popup.setPosition(coordinate);
map.addOverlay(popup);

Hierarchy (view full)

Constructors

  • Parameters

    • options: Options

      Overlay options.

    Returns Overlay

Properties

autoPan: undefined | PanIntoViewOptions
disposed: boolean

The object has already been disposed.

element: HTMLElement
id: undefined | string | number
insertFirst: boolean
mapPostrenderListenerKey: null | EventsKey
on: OverlayOnSignature<EventsKey>
once: OverlayOnSignature<EventsKey>
options: Options
rendered: {
    transform_: string;
    visible: boolean;
}
stopEvent: boolean
un: OverlayOnSignature<void>

Methods

  • Parameters

    • key: string

      Key name.

    • listener: Listener

      Listener.

    Returns void

  • Parameters

    • type: string

      Type.

    • listener: Listener

      Listener.

    Returns void

  • Protected

    Apply any properties from another object without triggering events.

    Parameters

    • source: Object

      The source object.

    Returns void

  • Increases the revision counter and dispatches a 'change' event.

    Returns void

  • Dispatches an event and calls all listeners listening for events of this type. The event parameter can either be a string or an Object with a type property.

    Parameters

    • event: string | BaseEvent

      Event object.

    Returns undefined | boolean

    false if anyone called preventDefault on the event object or if any of the listeners returned false.

  • Clean up.

    Returns void

  • Protected

    Extension point for disposable objects.

    Returns void

  • Gets a value.

    Parameters

    • key: string

      Key name.

    Returns any

    Value.

  • Get the DOM element of this overlay.

    Returns undefined | HTMLElement

    The Element containing the overlay.

  • Get the overlay identifier which is set on constructor.

    Returns undefined | string | number

    Id.

  • Get a list of object property names.

    Returns string[]

    List of property names.

  • Get the listeners for a specified event type. Listeners are returned in the order that they will be called in.

    Parameters

    • type: string

      Type.

    Returns undefined | Listener[]

    Listeners.

  • Get the map associated with this overlay.

    Returns null | external.ol.Map

    The map that the overlay is part of.

  • Get the offset of this overlay.

    Returns number[]

    The offset.

  • returns the options this Overlay has been created with

    Returns Options

    overlay options

  • Get the current position of this overlay.

    Returns undefined | Coordinate

    The spatial point that the overlay is anchored at.

  • Get the current positioning of this overlay.

    Returns Positioning

    How the overlay is positioned relative to its point on the map.

  • Get an object of all property names and values.

    Returns {
        [x: string]: any;
    }

    Object.

    • [x: string]: any
  • Get an object of all property names and values.

    Returns null | {
        [x: string]: any;
    }

    Object.

  • Protected

    Get the extent of an element relative to the document

    Parameters

    • element: HTMLElement

      The element.

    • size: Size

      The size of the element.

    Returns Extent

    The extent.

  • Get the version number for this object. Each time the object is modified, its version number will be incremented.

    Returns number

    Revision.

  • Protected

    Returns void

  • Protected

    Returns void

  • Protected

    Returns void

  • Protected

    Returns void

  • Protected

    Returns void

  • Parameters

    • Optionaltype: string

      Type. If not provided, true will be returned if this event target has any listeners.

    Returns boolean

    Has listeners.

  • Returns boolean

    The object has properties.

  • Parameters

    • key: string

      Key name.

    • oldValue: any

      Old value.

    Returns void

  • Protected

    Parameters

    • type: string | string[]

      Type.

    • listener: ((arg0: Event | BaseEvent) => unknown)

      Listener.

        • (arg0): unknown
        • Parameters

          • arg0: Event | BaseEvent

          Returns unknown

    Returns EventsKey | EventsKey[]

    Event key.

  • Protected

    Parameters

    • type: string | string[]

      Type.

    • listener: ((arg0: Event | BaseEvent) => unknown)

      Listener.

        • (arg0): unknown
        • Parameters

          • arg0: Event | BaseEvent

          Returns unknown

    Returns EventsKey | EventsKey[]

    Event key.

  • Pan the map so that the overlay is entirely visible in the current viewport (if necessary).

    Parameters

    • OptionalpanIntoViewOptions: PanIntoViewOptions

      Options for the pan action

    Returns void

  • Protected

    Pan the map so that the overlay is entirely visible in the current viewport (if necessary) using the configured autoPan parameters

    Returns void

  • Parameters

    • key: string

      Key name.

    • listener: Listener

      Listener.

    Returns void

  • Parameters

    • type: string

      Type.

    • listener: Listener

      Listener.

    Returns void

  • Protected

    Returns void

  • Sets a value.

    Parameters

    • key: string

      Key name.

    • value: any

      Value.

    • Optionalsilent: boolean

      Update without triggering an event.

    Returns void

  • Set the DOM element to be associated with this overlay.

    Parameters

    • element: undefined | HTMLElement

      The Element containing the overlay.

    Returns void

  • Set the map to be associated with this overlay.

    Parameters

    • map: null | external.ol.Map

      The map that the overlay is part of. Pass null to just remove the overlay from the current map.

    Returns void

  • Set the offset for this overlay.

    Parameters

    • offset: number[]

      Offset.

    Returns void

  • Set the position for this overlay. If the position is undefined the overlay is hidden.

    Parameters

    • position: undefined | Coordinate

      The spatial point that the overlay is anchored at.

    Returns void

  • Set the positioning for this overlay.

    Parameters

    • positioning: Positioning

      how the overlay is positioned relative to its point on the map.

    Returns void

  • Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties).

    Parameters

    • values: {
          [x: string]: any;
      }

      Values.

      • [x: string]: any
    • Optionalsilent: boolean

      Update without triggering an event.

    Returns void

  • Protected

    Modify the visibility of the element.

    Parameters

    • visible: boolean

      Element visibility.

    Returns void

  • Protected

    Unlisten for a certain type of event.

    Parameters

    • type: string | string[]

      Type.

    • listener: ((arg0: Event | BaseEvent) => unknown)

      Listener.

        • (arg0): unknown
        • Parameters

          • arg0: Event | BaseEvent

          Returns unknown

    Returns void

  • Unsets a property.

    Parameters

    • key: string

      Key name.

    • Optionalsilent: boolean

      Unset without triggering an event.

    Returns void

  • Protected

    Update pixel position.

    Returns void

  • Protected

    Parameters

    • pixel: Pixel

      The pixel location.

    • mapSize: undefined | Size

      The map size.

    Returns void