---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md
  - https://yandex.com/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/IGeoObjectCollection.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/jsapi-v2-1/doc/en/llms.txt

# IGeoObjectCollection

Extends [ICustomizable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICustomizable.md), [IEventEmitter](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IEventEmitter.md), [IParentOnMap](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IParentOnMap.md).

Interface of a collection of geo objects.

[Constructor](#constructor-summary) | [Fields](#properties-summary) | [Events](#events-summary) | [Methods](#methods-summary)

## Constructor {#constructor-summary}

```javascript
IGeoObjectCollection()
```

## Fields {#properties-summary}

#|
|| **Name** | **Type** | **Description** ||
|| [events](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IEventEmitter.md#events) | [IEventManager](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IEventManager.md) | Event manager.

Inherited from [IEventEmitter](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IEventEmitter.md#events). ||
|| [options](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICustomizable.md#options) | [IOptionManager](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IOptionManager.md) | Options manager.

Inherited from [ICustomizable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICustomizable.md#options). ||
|#

## Events {#events-summary}

#|
|| **Name** | **Description** ||
|| [add](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-add) | A child geo object has been added (inserted). Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- index: Integer - Index of the added geo object.
- child: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the added geo object. ||
|| [boundschange](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-boundschange) | Change to coordinates of the geographical area that spans the collection and its child geo objects. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. ||
|| [mapchange](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IParentOnMap.md#event-mapchange) | Map reference changed. Data fields: 
- oldMap - Old map.
- newMap - New map.

Inherited from [IParentOnMap](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IParentOnMap.md#event-mapchange). ||
|| [optionschange](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICustomizable.md#event-optionschange) | Change to the object options.

Inherited from [ICustomizable](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICustomizable.md#event-optionschange). ||
|| [pixelboundschange](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-pixelboundschange) | Change to pixel coordinates of the area that includes the collection and its child geo objects. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. ||
|| [remove](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-remove) | A child geo object has been removed. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- index: Integer - Index of the deleted geo object.
- child: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the deleted geo object. ||
|| [set](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-set) | A new child geo object has been added to the collection. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- index: Integer - Index of the geo object.
- child: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the new geo object.
- prevChild: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the previous value for this index. ||
|#

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [add](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#add)([child](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#add-param-child)[, [index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#add-param-index)]) | [IGeoObjectCollection](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md) | Adds (inserts) a child geo object to the collection. ||
|| [each](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#each)([callback](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#each-param-callback)[, [context](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#each-param-context)]) | | Calls a handler function for each child geo object. ||
|| [get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#get)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#get-param-index)) | [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) | Returns a child geo object with the specified index. ||
|| [getBounds](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#getBounds)() | Number[][]\|null | Returns geographical coordinates of the area that covers the collection and its child geo objects. ||
|| [getIterator](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#getIterator)() | [IIterator](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IIterator.md) | Returns iterator for the collection. ||
|| [getLength](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#getLength)() | Integer | Returns length of the collection. ||
|| [getMap](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IParentOnMap.md#getMap)() | [Map](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md) | Returns reference to the map.

Inherited from [IParentOnMap](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IParentOnMap.md#getMap). ||
|| [getPixelBounds](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#getPixelBounds)() | Number[][]\|null | Returns global pixel coordinates of the area that spans the collection and its child geo objects. ||
|| [indexOf](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#indexOf)([object](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#indexOf-param-object)) | Integer | Returns index of the child geo object. If the geo object cannot be found in the collection, -1 is returned. ||
|| [remove](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#remove)([child](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#remove-param-child)) | [IGeoObjectCollection](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md) | Removes a child geo object from the collection. ||
|| [removeAll](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#removeAll)() | [IGeoObjectCollection](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md) | Clears the collection. ||
|| [set](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#set)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#set-param-index), [child](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#set-param-child)) | [IGeoObjectCollection](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md) | Adds a new child geo object to the collection. ||
|| [splice](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#splice)([index](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#splice-param-index), [number](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#splice-param-number)) | [IGeoObjectCollection](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md) | Removes geo objects from the collection. If necessary, puts other objects in their place. Objects that will be added in place of the deleted ones are passed as additional parameters (after the "number" parameter). ||
|#

## Events details {#event_detail}

### add {#add}

A child geo object has been added (inserted). Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- index: Integer - Index of the added geo object.
- child: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the added geo object.

### boundschange {#boundschange}

Change to coordinates of the geographical area that spans the collection and its child geo objects. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class.

### pixelboundschange {#pixelboundschange}

Change to pixel coordinates of the area that includes the collection and its child geo objects. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class.

### remove {#remove}

A child geo object has been removed. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- index: Integer - Index of the deleted geo object.
- child: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the deleted geo object.

### set {#set}

A new child geo object has been added to the collection. Instance of the [Event](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. Names of fields that are available via the [Event.get](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#get) method: 
- index: Integer - Index of the geo object.
- child: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the new geo object.
- prevChild: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the previous value for this index.

## Methods details {#method_detail}

### add {#add}

```javascript
{IGeoObjectCollection} add(child[, index])
```

Adds (inserts) a child geo object to the collection.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`child`](#add-param-child)[*](*star) | — | Type: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)

Child object. ||
|| [`index`](#add-param-index) | — | Type: Integer

The index where the new object is added. By default, the object is added to the end of the collection. ||
|#

\* Mandatory parameter/option.

### each {#each}

```javascript
{} each(callback[, context])
```

Calls a handler function for each child geo object.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`callback`](#each-param-callback)[*](*star) | — | Type: Function

Handler function. ||
|| [`context`](#each-param-context) | — | Type: Object

Context for the handler function. ||
|#

\* Mandatory parameter/option.

### get {#get}

```javascript
{IGeoObject} get(index)
```

**Returns** a child geo object with the specified index.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#get-param-index)[*](*star) | — | Type: Integer

Index. ||
|#

\* Mandatory parameter/option.

### getBounds {#getBounds}

```javascript
{Number[][]|null} getBounds()
```

**Returns** geographical coordinates of the area that covers the collection and its child geo objects.

### getIterator {#getIterator}

```javascript
{IIterator} getIterator()
```

**Returns** iterator for the collection.

### getLength {#getLength}

```javascript
{Integer} getLength()
```

**Returns** length of the collection.

### getPixelBounds {#getPixelBounds}

```javascript
{Number[][]|null} getPixelBounds()
```

**Returns** global pixel coordinates of the area that spans the collection and its child geo objects.

### indexOf {#indexOf}

```javascript
{Integer} indexOf(object)
```

**Returns** index of the child geo object. If the geo object cannot be found in the collection, -1 is returned.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`object`](#indexOf-param-object)[*](*star) | — | Type: Object

Child object. ||
|#

\* Mandatory parameter/option.

### remove {#remove}

```javascript
{IGeoObjectCollection} remove(child)
```

Removes a child geo object from the collection.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`child`](#remove-param-child)[*](*star) | — | Type: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)

Geo object being removed. ||
|#

\* Mandatory parameter/option.

### removeAll {#removeAll}

```javascript
{IGeoObjectCollection} removeAll()
```

Clears the collection.

**Returns** self-reference.

### set {#set}

```javascript
{IGeoObjectCollection} set(index, child)
```

Adds a new child geo object to the collection.

**Returns** self-reference.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#set-param-index)[*](*star) | — | Type: Integer

Index. ||
|| [`child`](#set-param-child)[*](*star) | — | Type: [IGeoObject](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)

Child object. ||
|#

\* Mandatory parameter/option.

### splice {#splice}

```javascript
{IGeoObjectCollection} splice(index, number)
```

Removes geo objects from the collection. If necessary, puts other objects in their place. Objects that will be added in place of the deleted ones are passed as additional parameters (after the "number" parameter).

**Returns** collection of deleted geo objects.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`index`](#splice-param-index)[*](*star) | — | Type: Integer

Index of the geo object to start deletion from. ||
|| [`number`](#splice-param-number)[*](*star) | — | Type: Integer

The number of geo objects to be deleted. ||
|#

\* Mandatory parameter/option.

[*star]: Mandatory parameter/option.