EntityCollection

new Cesium.EntityCollection(owner)

A collection of entity objects, each entity in the collection has a unique identifier.
Name Type Description
owner DataSource | CompositeEntityCollection optional The datasource (or composite entity collection) that created this collection.

Members

readonlycollectionChanged : Event

Get the event triggered when an entity is added or deleted from the collection. The event generated is EntityCollection.collectionChangedEventCallback.

readonlyid : String

Get the globally unique identifier of this collection.
Get the owner of this entity collection, that is, the datasource or composite entity collection that created it.

show : Boolean

Get whether this entity collection is displayed. If this attribute is true, you also need to set the show attribute of the entity to true before it can be displayed.

readonlyvalues : Array.<Entity>

Get the array of entities in the collection. This array cannot be modified directly.

Methods

staticCesium.EntityCollection.collectionChangedEventCallback(collection, added, removed, changed)

Event signature generated by collection change EntityCollection#collectionChanged.
Name Type Description
collection EntityCollection The collection of trigger events.
added Array.<Entity> An array of Entity instances of entities that have been added to the collection.
removed Array.<Entity> An array of Entity instances of entities that have been removed from the collection.
changed Array.<Entity> The modified entity Entity instance array.

add(entity)Entity

Add an entity object to the entity collection.
Name Type Description
entity Entity The entity object to be added.
Returns:
Return true if added successfully, otherwise false.
Throws:
  • DeveloperError : An entity with this id identifier already exists in the collection.

computeAvailability()TimeInterval

Calculate the maximum availability of physical objects in the collection. If the set contains mixed available and unavailable data, the interval of unavailable data is returned. If all data is available, the range of available data is returned.
Returns:
The availability of physical objects in the collection.

contains(entity)Boolean

Determine whether the entity object already exists in the collection.
Name Type Description
entity Entity The specified entity object.
Returns:
The entity object has returned true in the collection, or false if it does not exist.

getById(id)Entity

Get the entity object with the specified id.
Name Type Description
id Object The id of the entity to be retrieved.
Returns:
The entity object with the specified id; if the entity with the id does not exist in the collection, undefined is returned.

getOrCreateEntity(id)Entity

Get the entity object with the specified ID or create an entity object. If the entity object does not exist in the collection, add it to the collection.
Name Type Description
id Object The ID of the entity object to be retrieved or created.
Returns:
Newly created or existing entity objects.

remove(entity)Boolean

Remove an entity object from the collection.
Name Type Description
entity Entity The entity object to be removed.
Returns:
Return true if the removal is successful; return false means that the entity does not exist in the collection and the removal failed.

removeAll()

Remove all entity objects in the collection.

removeById(id)Boolean

Remove the entity object with the specified id in the collection.
Name Type Description
id Object The id of the entity to be removed.
Returns:
If the removal succeeds, it returns true; if the entity with the specified id does not exist in the collection, it returns false if the removal fails.

resumeEvents()

Re-trigger the EntityCollection#collectionChanged event when adding or deleting items. When the event is paused, any modification made will trigger this event as an event. As long as the call EntityCollection#resumeEvents request, the event can be called multiple times.
Throws:
  • DeveloperError : resumeEvents is triggered after the suspendEvents event.

suspendEvents()

Before calling EntityCollection#resumeEvents, prevent the EntityCollection#collectionChanged event from being triggered, trigger an event for all stopped operations, and effectively add or delete many items. The event can be called multiple times as long as the call EntityCollection#resumeEvents request is issued.