EntityCollection Class


Deprecated: This class is deprecated in Bing Maps V8. The new Layer class should be used instead. This class is still available in V8, but has been added to provide partial backwards compatibility with V7 apps for simple use cases such as adding individual shapes directly to the map, rather than to a layer or collection.


The EntityCollection class has the following methods.

NameReturn TypeDescription
clear()Removes all shapes from the collection.
get(index: number)IPrimitiveReturns the shape at the specified index in the collection.
getLength()numberReturns the number of shapes in the collection.
indexOf(primitive: IPrimitive)numberReturns the index of the specified shape in the collection. If the entity is not found in the collection, -1 is returned.
insert(primitive: IPrimitive or IPrimitive[], index: number)Inserts the specified shape(s) into the collection at the given index.
pop()IPrimitiveRemoves the last shape from the collection and returns it.
push(primitive: IPrimitive or IPrimitive[])Adds the specified shape(s) to the last position in the collection.
remove(primitive: IPrimitive)IPrimitiveRemoves the specified shape from the collection and returns it.
removeAt(index: number)IPrimitiveRemoves the shape at the specified index from the collection and returns it.
entityaddedEntityCollectionChangedEventArgsOccurs when an IPrimitive (Pushpin, Polyline, Polygon) is added to the EntityCollection.
entityremovedEntityCollectionChangedEventArgsOccurs when an IPrimitive (Pushpin, Polyline, Polygon) is removed from the EntityCollection.

Note for Bing Maps V7 developers: In the Bing Maps V7 SDK, the EntityCollection class was used to create data layers on the map. This class has been deprecated and replaced with the Layer class. However, to minimize migration efforts we have added an EntityCollection class for backwards compatibility which wraps the Layer class. This wrapper flattens all child entity collections of an EntityCollection into a single layer. This may result in some rendering differences when compared to V7. This EntityCollection class should only be used if migrating an app from V7 that requires minimal code changes.