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

# map.GeoObjects

Extends [IGeoObjectCollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md).

Collection of map geo objects. Each map already has its own geo objects collection, available as map.geoObjects. Don't instantiate new instances of this class unless necessary.

**See** [Map.geoObjects](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.md#geoObjects)

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

## Constructor {#constructor-summary}

```javascript
map.GeoObjects(map[, options])
```

**Parameters:**

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

Map. ||
|| [`options`](#param-options) | — | Type: Object

Options of a collection of geo objects. The map.geoObjects options can be used to make settings for geo objects that have been added to the map: 
- Options for [clusterers](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Clusterer.md) with the `clusterer` prefix.
- Options for [clusters](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ClusterPlacemark.md) with the `cluster` prefix. ||
|#

\* Mandatory parameter/option.

## Fields {#properties-summary}

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

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

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

## Events {#events-summary}

#|
|| **Name** | **Description** ||
|| [add](https://yandex.com.tr/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.tr/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.tr/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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the added geo object.

Inherited from [IGeoObjectCollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-add). ||
|| [boundschange](https://yandex.com.tr/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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class.

Inherited from [IGeoObjectCollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-boundschange). ||
|| [mapchange](https://yandex.com.tr/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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IParentOnMap.md#event-mapchange). ||
|| [optionschange](https://yandex.com.tr/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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICustomizable.md#event-optionschange). ||
|| [pixelboundschange](https://yandex.com.tr/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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class.

Inherited from [IGeoObjectCollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-pixelboundschange). ||
|| [remove](https://yandex.com.tr/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.tr/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.tr/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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the deleted geo object.

Inherited from [IGeoObjectCollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObjectCollection.md#event-remove). ||
|| [set](https://yandex.com.tr/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.tr/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.tr/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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the new geo object.
- prevChild: [IGeoObject](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md) - Reference to the previous value for this index.

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

## Methods {#methods-summary}

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

Inherited from [IParentOnMap](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IParentOnMap.md#getMap). ||
|| [getPixelBounds](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#getPixelBounds)() | Number[][]\|null | Returns global pixel coordinates of the area that spans the collection and its child geo objects. ||
|| [indexOf](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#indexOf)([object](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#remove)([child](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#remove-param-child)) | [map.GeoObjects](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md) | Removes a child geo object from the collection. ||
|| [removeAll](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#removeAll)() | [map.GeoObjects](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md) | Clears the collection. ||
|| [set](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#set)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#set-param-index), [child](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#set-param-child)) | [map.GeoObjects](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md) | Adds a new child geo object to the collection. ||
|| [splice](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#splice)([index](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#splice-param-index), [number](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects.md#splice-param-number)) | [GeoObjectCollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObjectCollection.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).||
|#

## Methods details {#method_detail}

### add {#add}

```javascript
{map.GeoObjects} 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.tr/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.

**Example:**

```javascript
// Displaying a geo object's index in a collection for its icon contents.
myGeoObjects.events.add(["add", "remove", "set"], function () {
    this.each(function (el, i) {
        el.properties.set("iconContent", i);
    })
}, myGeoObjects);
```

### 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
{map.GeoObjects} 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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)

Geo object being removed. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// When a geo object is clicked, we remove it from the collection.
myGeoObjects.events.add("click", function (e) {
    if (e.get("target").getParent() == this) {
        this.remove(e.get("target"));
    }
}, myGeoObjects);
```

### removeAll {#removeAll}

```javascript
{map.GeoObjects} removeAll()
```

Clears the collection.

**Returns** self-reference.

### set {#set}

```javascript
{map.GeoObjects} 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.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeoObject.md)

Child object. ||
|#

\* Mandatory parameter/option.

### splice {#splice}

```javascript
{GeoObjectCollection} 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.

**Example:**

```javascript
// Removes the second object.
myGeoObjects.splice(1, 1);
// Puts a new "obj" object in the second position.
myGeoObjects.splice(1, 0, obj);
// Replaces the second object with the new "obj" object.
myGeoObjects.splice(1, 1, obj);
```

[*star]: Mandatory parameter/option.