DataSourceCollection

new Cesium.DataSourceCollection()

数据源DataSource实例对象的集合。

Members

readonlydataSourceAdded : Event

将数据源添加到此集合时触发的事件。 由事件处理程序传递被添加的数据源。

readonlydataSourceRemoved : Event

移除集合中的数据源时触发的事件。 由事件处理程序传递被移除的数据源。

readonlylength : Number

获取集合中的数据源个数。

Methods

add(dataSource)Promise.<DataSource>

向集合添加一个数据源。
Name Type Description
dataSource DataSource | Promise.<DataSource> 待添加的数据源或数据源的promise。传递promise时,直至解析成功前,数据源不会真正添加到集合中。
Returns:
数据源添加到集合中后所解析的promise。

contains(dataSource)Boolean

检测集合中是否包含指定的数据源。
Name Type Description
dataSource DataSource 待检索的数据源。
Returns:
集合中包含返回true,否则返回false。

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:

get(index)DataSource

获取集合中指定索引号的数据源。
Name Type Description
index Number the index to retrieve.
Returns:
The data source at the specified index.

indexOf(dataSource)Number

确定指定数据源在集合中的索引号。
Name Type Description
dataSource DataSource 待检索的数据源。
Returns:
数据源在集合中的索引号,如果集合不包含该数据源,返回-1。

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:

remove(dataSource, destroy)Boolean

移除集合中的一个数据源(如果存在)。
Name Type Default Description
dataSource DataSource 待移除的数据源。
destroy Boolean false optional 指定是否在移除后销毁数据源。
Returns:
集合中存在该数据源并被移除后,返回true;如果集合中不存在该数据源,移除失败,返回false。

removeAll(destroy)

移除集合中的所有数据源。
Name Type Default Description
destroy Boolean false optional 指定是否在移除后销毁数据源。