Classdesc

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);

Api

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;
}

Type declaration

  • 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

    Api

  • 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.

    Api

  • Clean up.

    Returns void

  • Protected

    Extension point for disposable objects.

    Returns void

  • Gets a value.

    Parameters

    • key: string

      Key name.

    Returns any

    Value.

    Api

  • Get the DOM element of this overlay.

    Returns undefined | HTMLElement

    The Element containing the overlay.

    Observable

    Api

  • Get the overlay identifier which is set on constructor.

    Returns undefined | string | number

    Id.

    Api

  • Get a list of object property names.

    Returns string[]

    List of property names.

    Api

  • 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.

    Observable

    Api

  • Get the offset of this overlay.

    Returns number[]

    The offset.

    Observable

    Api

  • 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.

    Observable

    Api

  • Get the current positioning of this overlay.

    Returns Positioning

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

    Observable

    Api

  • Get an object of all property names and values.

    Returns {
        [x: string]: any;
    }

    Object.

    • [x: string]: any

    Api

  • 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.

    Api

  • Protected

    Returns void

  • Protected

    Returns void

  • Protected

    Returns void

  • Protected

    Returns void

  • Protected

    Returns void

  • Parameters

    • Optional type: 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) => unknown)

      Listener.

        • (arg0): unknown
        • Parameters

          • arg0: Event | BaseEvent

          Returns unknown

    Returns EventsKey | EventsKey[]

    Event key.

  • Protected

    Parameters

    • type: string | string[]

      Type.

    • listener: ((arg0) => 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

    • Optional panIntoViewOptions: PanIntoViewOptions

      Options for the pan action

    Returns void

    Api

  • 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.

    • Optional silent: boolean

      Update without triggering an event.

    Returns void

    Api

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

    Parameters

    • element: undefined | HTMLElement

      The Element containing the overlay.

    Returns void

    Observable

    Api

  • 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

    Observable

    Api

  • Set the offset for this overlay.

    Parameters

    • offset: number[]

      Offset.

    Returns void

    Observable

    Api

  • 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

    Observable

    Api

  • Set the positioning for this overlay.

    Parameters

    • positioning: Positioning

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

    Returns void

    Observable

    Api

  • 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
    • Optional silent: boolean

      Update without triggering an event.

    Returns void

    Api

  • 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) => unknown)

      Listener.

        • (arg0): unknown
        • Parameters

          • arg0: Event | BaseEvent

          Returns unknown

    Returns void

  • Unsets a property.

    Parameters

    • key: string

      Key name.

    • Optional silent: boolean

      Unset without triggering an event.

    Returns void

    Api

  • Protected

    Update pixel position.

    Returns void

  • Protected

    Parameters

    • pixel: Pixel

      The pixel location.

    • mapSize: undefined | Size

      The map size.

    Returns void