MMapCollection

MMapCollection 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 MMapCollection({});
const markerElement = document.createElement('div');
markerElement.className = 'marker';

for (let i = 0; i < 10_000; i++) {
 collection.addChild(new MMapMarker({
   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 MMapCollection(props, options?)

Constructor parameters

Parameter

Type

Description

props

Object

Value of input props.

options?

ComplexOptions<MMap>

Optional parameters.

Inherited from

MMapGroupEntity.constructor

new MMapCollection(props, children?, options?)

Constructor parameters

Parameter

Type

props

Object

children?

MMapEntity

options?

Omit<ComplexOptions<MMap>, "children">

Inherited from

MMapGroupEntity.constructor

Props

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

Inherited from

MMapGroupEntity.children

Methods

addChild

addChild(child, index?): MMapCollection

Parameters

Parameter

Type

child

MMapEntity<unknown, {}>

index?

number

Returns

MMapCollection

Inherited from

MMapGroupEntity.addChild

removeChild

removeChild(child): MMapCollection

Parameters

Parameter

Type

child

MMapEntity<unknown, {}>

Returns

MMapCollection

Inherited from

MMapGroupEntity.removeChild

update

update(changedProps): void

Parameters

Parameter

Type

Description

changedProps

Partial<{}>

New props values.

Returns

void

Inherited from

MMapGroupEntity.update