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

# LayerCollection

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

Collection of layers.

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

## Constructor {#constructor-summary}

```javascript
LayerCollection([options])
```

Collection of layers.

**Parameters:**

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

Layer options. ||
|#

## 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/ICollection.md#event-add) | A child object was added.

Inherited from [ICollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICollection.md#event-add). ||
|| [brightnesschange](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md#event-brightnesschange) | Layer brightness change event.

Inherited from [ILayer](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md#event-brightnesschange). ||
|| [copyrightschange](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md#event-copyrightschange) | Event for changes to available copyright information.

Inherited from [ILayer](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md#event-copyrightschange). ||
|| [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). ||
|| [parentchange](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IChild.md#event-parentchange) | The parent object reference changed.

Data fields:

- oldParent - Old parent.
- newParent - New parent.

Inherited from [IChild](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IChild.md#event-parentchange). ||
|| [remove](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICollection.md#event-remove) | A child object was deleted.

Inherited from [ICollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICollection.md#event-remove). ||
|| [tileloadchange](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md#event-tileloadchange) | Tile upload status change event. Data fields: 
- readyTileNumber - Number of ready tiles. A tile is considered ready when it is downloaded and rendered. Type: Number.
- totalTileNumber - Total number of visible tiles. Type: Number.

Inherited from [ILayer](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md#event-tileloadchange). ||
|| [zoomrangechange](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md#event-zoomrangechange) | Event for changes to available information about the zoom level range.

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

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [add](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#add)([child](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#add-param-child)) | [LayerCollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md) | Adds a child object to the collection. ||
|| [each](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#each)([callback](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#each-param-callback)[, [context](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#each-param-context)]) | | Iterates through all the items in the collection and calls a handler function for each of them. ||
|| [getBrightness](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#getBrightness)() | Number | Returns layer brightness as a number from 0 to 1. ||
|| [getCopyrights](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#getCopyrights)(\[[coords](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#getCopyrights-param-coords)[, [zoom](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#getCopyrights-param-zoom)]]) | [vow.Promise](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/vow.Promise.md) | Requests information about copyrights at the specified point with the specified zoom. If the point and zoom are omitted, it uses the map center and zoom. ||
|| [getIterator](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICollection.md#getIterator)() | [IIterator](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IIterator.md) | Returns iterator for the collection.

Inherited from [ICollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ICollection.md#getIterator). ||
|| [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). ||
|| [getParent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IChildOnMap.md#getParent)() | [IParentOnMap](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IParentOnMap.md)\|null | Returns link to the parent object, or null if the parent element was not set.

Inherited from [IChildOnMap](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IChildOnMap.md#getParent). ||
|| [getZoomRange](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#getZoomRange)(\[[coords](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#getZoomRange-param-coords)]) | [vow.Promise](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/vow.Promise.md) | Checks the available range of zoom levels at the specified point. If there is data, the returned promise object will be resolved and will pass as a result an array of two numbers - the minimum and maximum zoom level available at the point. If there is no data, the promise is rejected with an error. If the collection does not have a single descendant providing information about the zoom level range, the promise will be rejected with the "noProvider" message. ||
|| [remove](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#remove)([child](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#remove-param-child)) | [LayerCollection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md) | Removes a child object from the collection. ||
|| [removeAll](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/LayerCollection.md#removeAll)() | [Collection](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Collection.md) | Deletes all the items from a collection. ||
|| [setParent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IChildOnMap.md#setParent)([parent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IChildOnMap.md#setParent-param-parent)) | [IChildOnMap](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IChildOnMap.md) | Sets the parent object. If the null value is passed, the manager element will only be deleted from the current parent object.

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

## Methods details {#method_detail}

### add {#add}

```javascript
{LayerCollection} add(child)
```

Adds a child object to the collection.

**Returns** self-reference.

**Parameters:**

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

Layer to add (key from [layer.storage](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/layer.storage.md) or an instance of the [ILayer](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md) class). ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Let's say we want to add several layers to our collection.
var layerCollection = new ymaps.LayerCollection();
var customLayer = new ymaps.Layer('http://tile.openstreetmap.org/%z/%x/%y.png', {
    projection: ymaps.projection.sphericalMercator
});
// We can use a key from layer.storage to set the layer.
var satelliteLayer = 'yandex#satellite';
// Adding layers to our collection.
layerCollection
    .add(customLayer)
    .add(satelliteLayer);
```

### each {#each}

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

Iterates through all the items in the collection and calls a handler function for each of them.

**Parameters:**

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

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

Context for the function. ||
|#

\* Mandatory parameter/option.

### getBrightness {#getBrightness}

```javascript
{Number} getBrightness()
```

**Returns** layer brightness as a number from 0 to 1.

### getCopyrights {#getCopyrights}

```javascript
{vow.Promise} getCopyrights([coords[, zoom]])
```

Requests information about copyrights at the specified point with the specified zoom. If the point and zoom are omitted, it uses the map center and zoom.

**Returns** a Promise object that will be resolved and will pass as a result an array of strings or DOM elements with information about copyrights.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`coords`](#getCopyrights-param-coords) | — | Type: Number[]

The point on the map that copyright information is being requested for. ||
|| [`zoom`](#getCopyrights-param-zoom) | — | Type: Number

The zoom level that copyright information is being requested for. ||
|#


**Example:**

```javascript
// Let's say we have a service that can return copyrights
// using the coordinates and zoom level
myLayer.getCopyrights = function (coords, zoom) {
    var deferred = ymaps.vow.defer();
    $.ajax('url/to/copyrights/provider?ll=' +
        (coords || map.getCenter()).join(',') + '&z=' +
        (zoom || map.getZoom()),
    function (res) {
        deferred.resolve(res || []);
    });
    return deferred.promise();
};
```

### getZoomRange {#getZoomRange}

```javascript
{vow.Promise} getZoomRange([coords])
```

Checks the available range of zoom levels at the specified point. If there is data, the returned promise object will be resolved and will pass as a result an array of two numbers - the minimum and maximum zoom level available at the point. If there is no data, the promise is rejected with an error. If the collection does not have a single descendant providing information about the zoom level range, the promise will be rejected with the "noProvider" message.

**Returns** Promise object.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`coords`](#getZoomRange-param-coords) | — | Type: Number[]

Coordinates of a point. If omitted, the current map center is used. ||
|#

**Example:**

```javascript
// Assuming that our layer was drawn for the 2-15 zoom level for the entire earth
myLayer.getZoomRange = function () {
    return ymaps.vow.resolve([2, 15]);
}
```

### remove {#remove}

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

Removes a child object from the collection.

**Returns** self-reference.

**Parameters:**

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

Layer to delete (key string from [layer.storage](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/layer.storage.md) or an instance of the [ILayer](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ILayer.md) class). ||
|#

\* Mandatory parameter/option.

### removeAll {#removeAll}

```javascript
{Collection} removeAll()
```

Deletes all the items from a collection.

**Returns** self-reference.

[*star]: Mandatory parameter/option.