Classdesc

An expanded version of standard JS Array, adding convenience methods for manipulation. Add and remove changes to the Collection trigger a Collection event. Note that this does not cover changes to the objects within the Collection; they trigger events on the appropriate object, not on the Collection as a whole.

Fires

ol.Collection.Event

Param: opt_array

Array.

Api

stable

Type Parameters

  • T

Hierarchy

Constructors

  • Type Parameters

    • T

    Parameters

    • Optional opt_array: T[]

      Array.

    Returns Collection<T>

    Classdesc

    An expanded version of standard JS Array, adding convenience methods for manipulation. Add and remove changes to the Collection trigger a Collection event. Note that this does not cover changes to the objects within the Collection; they trigger events on the appropriate object, not on the Collection as a whole.

    Fires

    ol.Collection.Event

    Api

    stable

Methods

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

    Returns void

    Api

  • Remove all elements from the collection.

    Returns void

    Api

    stable

  • 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

    Returns void

    Function

    Api

  • Add elements to the collection. This pushes each item in the provided array to the end of the collection.

    Parameters

    • arr: T[]

      Array.

    Returns Collection<T>

    This collection.

    Api

    stable

  • Iterate over each element, calling the provided callback.

    Type Parameters

    • S

    Parameters

    • f: ((item, index, array) => any)

      The function to call for every element. This function takes 3 arguments (the element, the index and the array). The return value is ignored.

        • (item, index, array): any
        • Parameters

          • item: T
          • index: number
          • array: T[]

          Returns any

    • Optional opt_this: S

      The object to use as this in f.

    Returns void

    Api

    stable

  • Gets a value.

    Parameters

    • key: string

      Key name.

    Returns any

    Value.

    Api

    stable

  • Get a reference to the underlying Array object. Warning: if the array is mutated, no events will be dispatched by the collection, and the collection's "length" property won't be in sync with the actual length of the array.

    Returns T[]

    Array.

    Api

    stable

  • Get a list of object property names.

    Returns string[]

    List of property names.

    Api

    stable

  • Get the length of this collection.

    Returns number

    The length of the array.

    Observable

    Api

    stable

  • Get an object of all property names and values.

    Returns {
        [k: string]: any;
    }

    Object.

    • [k: string]: any

    Api

    stable

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

    Returns number

    Revision.

    Api

  • Insert an element at the provided index.

    Parameters

    • index: number

      Index.

    • elem: T

      Element.

    Returns void

    Api

    stable

  • Get the element at the provided index.

    Parameters

    • index: number

      Index.

    Returns T

    Element.

    Api

    stable

  • Listen for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object to use as this in listener.

    Returns Object | Object[]

    Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

    Api

    stable

  • Listen once for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object to use as this in listener.

    Returns Object | Object[]

    Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

    Api

    stable

  • Remove the last element of the collection and return it. Return undefined if the collection is empty.

    Returns T

    Element.

    Api

    stable

  • Insert the provided element at the end of the collection.

    Parameters

    • elem: T

      Element.

    Returns number

    Length.

    Api

    stable

  • Remove the first occurrence of an element from the collection.

    Parameters

    • elem: T

      Element.

    Returns T

    The removed element or undefined if none found.

    Api

    stable

  • Remove the element at the provided index and return it. Return undefined if the collection does not contain this index.

    Parameters

    • index: number

      Index.

    Returns T

    Value.

    Api

    stable

  • Sets a value.

    Parameters

    • key: string

      Key name.

    • value: any

      Value.

    • Optional opt_silent: boolean

      Update without triggering an event.

    Returns void

    Api

    stable

  • Set the element at the provided index.

    Parameters

    • index: number

      Index.

    • elem: T

      Element.

    Returns void

    Api

    stable

  • 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: {
          [k: string]: any;
      }

      Values.

      • [k: string]: any
    • Optional opt_silent: boolean

      Update without triggering an event.

    Returns void

    Api

    stable

  • Unlisten for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object which was used as this by the listener.

    Returns void

    Api

    stable

  • Removes an event listener using the key returned by on() or once().

    Parameters

    • key: Object | Object[]

      The key returned by on() or once() (or an array of keys).

    Returns void

    Api

    stable

  • Removes an event listener using the key returned by on() or once(). Note that using the ol.Observable.unByKey static function is to be preferred.

    Parameters

    • key: Object | Object[]

      The key returned by on() or once() (or an array of keys).

    Returns void

    Function

    Api

    stable

  • Unsets a property.

    Parameters

    • key: string

      Key name.

    • Optional opt_silent: boolean

      Unset without triggering an event.

    Returns void

    Api

    stable

Generated using TypeDoc