Teilen über


EntityCollection Class

Note

Bing Maps Web Control SDK retirement

Bing Maps Web Control SDK is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps Web Control SDK until June 30th, 2025. Enterprise account customers can continue to use Bing Maps Web Control SDK until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps Web Control SDK will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type. For detailed migration guidance, see Migrate from Bing Maps Web Control SDK and Migrate Bing Maps Enterprise applications to Azure Maps with GitHub Copilot.

Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.

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.

Constructor

EntityCollection()

Methods

The EntityCollection class has the following methods.

Name Return Type Description
clear() Removes all shapes from the collection.
get(index: number) IPrimitive Returns the shape at the specified index in the collection.
getLength() number Returns the number of shapes in the collection.
indexOf(primitive: IPrimitive) number Returns 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() IPrimitive Removes 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) IPrimitive Removes the specified shape from the collection and returns it.
removeAt(index: number) IPrimitive Removes the shape at the specified index from the collection and returns it.

Events

Name Type Description
entityadded EntityCollectionChangedEventArgs Occurs when an IPrimitive (Pushpin, Polyline, Polygon) is added to the EntityCollection.
entityremoved EntityCollectionChangedEventArgs Occurs 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.