EntityCollection

new Cesium.EntityCollection(owner)

一个可观察的 Entity 实例集合,其中每个实体都有唯一的 id。
Name Type Description
owner DataSource | CompositeEntityCollection optional 创建此集合的数据源(或复合实体集合)。

Members

获取当实体从集合中添加或移除时触发的事件。 生成的事件是 EntityCollection.CollectionChangedEventCallback
获取此集合的全局唯一标识符。
获取此实体集合的所有者,即创建它的数据源或复合实体集合。
获取此实体集合是否应被显示。 当为 true 时,每个实体仅在自身的 show 属性也为 true 时才显示。
获取集合中的 Entity 实例数组。 不应直接修改此数组。

Methods

向集合中添加实体。
Name Type Description
entity Entity | Entity.ConstructorOptions 要添加的实体。
Returns:
被添加的实体。
Throws:
计算集合中实体的最大可用性。 如果集合包含无限可用数据和非无限数据的混合, 它将仅返回与非无限数据相关的间隔。如果所有 数据都是无限的,则将返回无限间隔。
Returns:
集合中实体的可用性。
如果提供的实体存在于此集合中则返回 true,否则返回 false。
Name Type Description
entity Entity 实体。
Returns:
如果提供的实体存在于此集合中则返回 true,否则返回 false。
Gets an entity with the specified id.
Name Type Description
id string The id of the entity to retrieve.
Returns:
The entity with the provided id or undefined if the id did not exist in the collection.
Gets an entity with the specified id or creates it and adds it to the collection if it does not exist.
Name Type Description
id string The id of the entity to retrieve or create.
Returns:
The new or existing object.
从集合中移除实体。
Name Type Description
entity Entity 要移除的实体。
Returns:
如果项目被移除则返回 true,如果不存在于集合中则返回 false。
从集合中移除所有实体。
从集合中移除具有提供的 id 的实体。
Name Type Description
id string 要移除的实体的 id。
Returns:
如果项目被移除则返回 true,如果集合中不存在具有提供的 id 的项目则返回 false。
当添加或移除项目时,立即恢复引发 EntityCollection#collectionChanged 事件。 在事件挂起期间所做的任何修改将在调用此函数时作为单个事件触发。 此函数是引用计数的,只要存在对 EntityCollection#resumeEvents 的相应调用, 就可以安全地多次调用。
Throws:
  • DeveloperError : 不能在 suspendEvents 之前调用 resumeEvents。
阻止引发 EntityCollection#collectionChanged 事件, 直到对 EntityCollection#resumeEvents 进行相应调用为止,此时 将引发一个涵盖所有挂起操作的事件。 这允许高效地添加和移除许多项目。 只要存在对 EntityCollection#resumeEvents 的相应调用, 就可以安全地多次调用此函数。

Type Definitions

Cesium.EntityCollection.CollectionChangedEventCallback(collection, added, removed, changed)

EntityCollection#collectionChanged 生成的事件的签名。
Name Type Description
collection EntityCollection 触发事件的对象集合。
added Array.<Entity> 已添加到集合中的 Entity 实例数组。
removed Array.<Entity> 已从集合中移除的 Entity 实例数组。
changed Array.<Entity> 已修改的 Entity 实例数组。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.