Export (0) Print
Expand All

EntityCollection Class (AdvancedShapes)

Bing

Contains a collection of entities. These collection of entities can represent a multiple shape entity on the map. When the Microsoft.Maps.AdvancedShapes module is loaded, this class inherits and replaces the basic EntityCollection class.

An Entity can be any one of the following types: Infobox, Polygon, Polyline, Pushpin, TileLayer, or EntityCollection.

Constructor

Name Definition Description

EntityCollection

EntityCollection(options?: EntityCollectionOptions )

Initializes a new instance of the EntityCollection class.

Methods

Name Definition Return Value Description

clear

clear()

None

Removes all entities from the collection.

get

get(index:number)

Entity*

Returns the entity at the specified index in the collection.

getLength

getLength()

number

Returns the number of entities in the collection.

getVisible

getVisible()

boolean

Returns whether the entity collection is visible on the map.

getZIndex

getZIndex()

number

Gets the z-index of the entity collection with respect to other items on the map.

indexOf

indexOf(entity:Entity*)

number

Returns the index of the specified entity in the collection. If the entity is not found in the collection, -1 is returned.

insert

insert(entity:Entity*, index:number)

None

Inserts the specified entity into the collection at the given index.

pop

pop()

Entity*

Removes the last entity from the collection and returns it.

push

push(entity:Entity*)

None

Adds the specified entity to the last position in the collection.

remove

remove(entity:Entity*)

Entity*

Removes the specified entity from the collection and returns it.

removeAt

removeAt(index:number)

Entity*

Removes the entity at the specified index from the collection and returns it.

setOptions

setOptions(options: EntityCollectionOptions )

None

Sets the options for the entity collection.

toString

toString()

string

Converts the EntityCollection object to a string.

* An Entity can be any one of the following types: Infobox, Polygon, Polyline, Pushpin, TileLayer, or EntityCollection.

Events

Name Arguments Description

entityadded

object: {collection: EntityCollection, entity:Entity*}

Occurs when one of the following happens:

  • An entity is added to the collection.

  • One of the entities of the collection (such as another entity collection) fires the entityadded event.

For example, if collection #1 contains an entity, which is another collection #2, then when an entity is added to collection #2, two entityadded events are fired.

entitychanged

object: {collection: EntityCollection, entity:Entity*}

Occurs when one of the following happens:

  • The collection changes.

  • An entity of the collection changes.

  • One of the entities of the collection (such as another entity collection) fires the entitychanged event.

For example, if collection #1 contains an entity, which is another collection #2, then when an entity of collection #2 changes, two entitychanged events are fired.

entityremoved

object: {collection: EntityCollection, entity:Entity*}

Occurs when one of the following happens:

  • An entity of the collection is removed.

  • One of the entities of the collection (such as another entity collection) fires the entityremoved event.

For example, if collection #1 contains an entity, which is another collection #2, then when an entity of collection #2 is removed, two entityremoved events are fired.

* An Entity can be any one of the following types: Infobox, Polygon, Polyline, Pushpin, TileLayer, or EntityCollection.

Remarks

The AdvancedShapes EntityCollection class differs from the base EntityCollection class in two ways:

  • When an entity of the collection fires an event, the event will fire for all entities of the collection. For example, if the mouseover event if fired for a pushpin in an entity collection, then the entity collection’s mouseover event is fired.

  • Setting the options of the entity collection sets the options of all its entities unless the entity collection option bubble is set to false. For example, by default, in an entity collection composed of multiple polygons, setting one polygon’s fill color to red changes the fill color of all of the other polygons in the entity collection to red.

Show:
© 2014 Microsoft