DataSourceCollection - Cesium Documentation

# DataSourceCollection

#### new DataSourceCollection()

  A collection of `DataSource` instances.
  Source: DataSources/DataSourceCollection.js, line 25

### Members

#### readonlydataSourceAdded :Event

  An event that is raised when a data source is added to the collection. Event handlers are passed the data source that was added.
  Source: DataSources/DataSourceCollection.js, line 51

#### readonlydataSourceRemoved :Event

  An event that is raised when a data source is removed from the collection. Event handlers are passed the data source that was removed.
  Source: DataSources/DataSourceCollection.js, line 64

#### readonlylength :Number

  Gets the number of data sources in this collection.
  Source: DataSources/DataSourceCollection.js, line 38

### Methods

#### add(dataSource) → Promise.<DataSource>

  Adds a data source to the collection.

  Name | Type | Description
  --- | --- | ---
  `dataSource` | DataSource | Promise.<DataSource> | A data source or a promise to a data source to add to the collection. When passing a promise, the data source will not actually be added to the collection until the promise resolves successfully.

  ##### Returns:

  A Promise that resolves once the data source has been added to the collection.
  Source: DataSources/DataSourceCollection.js, line 79

#### contains(dataSource) → Boolean

  Checks to see if the collection contains a given data source.

  Name | Type | Description
  --- | --- | ---
  `dataSource` | DataSource | The data source to check for.

  ##### Returns:

  true if the collection contains the data source, false otherwise.
  Source: DataSources/DataSourceCollection.js, line 151

#### destroy() → undefined

  Destroys the resources held by all data sources in this collection. Explicitly destroying this object allows for deterministic release of WebGL resources, instead of relying on the garbage collector. Once this object is destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception. Therefore, assign the return value (`undefined`) to the object as done in the example.

  ##### Returns:

  ##### Throws:

  - DeveloperError : This object was destroyed, i.e., destroy() was called.

  ##### Example:

      dataSourceCollection = dataSourceCollection && dataSourceCollection.destroy();

  ##### See:

  - DataSourceCollection#isDestroyed
  Source: DataSources/DataSourceCollection.js, line 209

#### get(index)

  Gets a data source by index from the collection.

  Name | Type | Description
  --- | --- | ---
  `index` | Number | the index to retrieve.

  Source: DataSources/DataSourceCollection.js, line 170

#### indexOf(dataSource) → Number

  Determines the index of a given data source in the collection.

  Name | Type | Description
  --- | --- | ---
  `dataSource` | DataSource | The data source to find the index of.

  ##### Returns:

  The index of the data source in the collection, or -1 if the data source does not exist in the collection.
  Source: DataSources/DataSourceCollection.js, line 161

#### isDestroyed() → Boolean

  Returns true if this object was destroyed; otherwise, false. If this object was destroyed, it should not be used; calling any function other than `isDestroyed` will result in a `DeveloperError` exception.

  ##### Returns:

  true if this object was destroyed; otherwise, false.

  ##### See:

  - DataSourceCollection#destroy
  Source: DataSources/DataSourceCollection.js, line 189

#### remove(dataSource, destroy) → Boolean

  Removes a data source from this collection, if present.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `dataSource` | DataSource |  | The data source to remove.
  `destroy` | Boolean | `false` | optional Whether to destroy the data source in addition to removing it.

  ##### Returns:

  true if the data source was in the collection and was removed, false if the data source was not in the collection.
  Source: DataSources/DataSourceCollection.js, line 107

#### removeAll(destroy)

  Removes all data sources from this collection.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `destroy` | Boolean | `false` | optional whether to destroy the data sources in addition to removing them.

  Source: DataSources/DataSourceCollection.js, line 130