YMapCollection

YMapCollection is a class that can combine multiple objects in a collection. It enables you to add objects to a subtree and remove them from it.

Creating a collection

Example of creating a collection of markers.

const collection = new YMapCollection({});
const markerElement = document.createElement('div');
markerElement.className = 'marker';

for (let i = 0; i < 10_000; i++) {
 collection.addChild(new YMapMarker({
   coordinates: [Math.random() * 180, Math.random() * 180]
 }, markerElement.cloneNode(true)));
}

map.addChild(collection); // add a collection to the map
map.removeChild(collection); // remove all markers from the map

Detailed example.

Constructor

new YMapCollection(props, options?)

Constructor parameters

Parameter

Type

Description

props

Object

Value of input props.

options?

ComplexOptions<YMap>

Optional parameters.

Inherited from

YMapGroupEntity.constructor

new YMapCollection(props, children?, options?)

Constructor parameters

Parameter

Type

props

Object

children?

YMapEntity

options?

Omit<ComplexOptions<YMap>, "children">

Inherited from

YMapGroupEntity.constructor

Props

readonly children: readonly [YMapEntity](YMapEntity.md)<unknown, {}>[]

Inherited from

YMapGroupEntity.children

Methods

addChild

addChild(child, index?): YMapCollection

Parameters

Parameter

Type

child

YMapEntity<unknown, {}>

index?

number

Returns

YMapCollection

Inherited from

YMapGroupEntity.addChild

removeChild

removeChild(child): YMapCollection

Parameters

Parameter

Type

child

YMapEntity<unknown, {}>

Returns

YMapCollection

Inherited from

YMapGroupEntity.removeChild

update

update(changedProps): void

Parameters

Parameter

Type

Description

changedProps

Partial<{}>

New props values.

Returns

void

Inherited from

YMapGroupEntity.update