---
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.Container.md
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/map.Container.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com.tr/dev/jsapi-v2-1/doc/en/llms.txt

# map.Container

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

Map container manager. Each map already has its own container manager, available as map.container. Don't instantiate new instances of this class unless necessary.

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

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

## Constructor {#constructor-summary}

```javascript
map.Container(parentElement)
```

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`parentElement`](#param-parentElement)[*](*star) | — | Type: String\|HTMLElement

HTML element (or its ID) where the map will be created. ||
|#

\* Mandatory parameter/option.

## Fields {#properties-summary}

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

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

## Events {#events-summary}

#|
|| **Name** | **Description** ||
|| [beforefullscreenexit](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#event-beforefullscreenexit) | The event preceding the "fullscreenexit" event. If the [Event.preventDefault](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#preventDefault) method is called for this event, a subsequent fullscreenexit event will be canceled. Instance of the [Event](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. ||
|| [click](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-click) | Single left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-click). ||
|| [contextmenu](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-contextmenu) | Calls the element's context menu. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-contextmenu). ||
|| [dblclick](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-dblclick) | Double left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-dblclick). ||
|| [fullscreenenter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#event-fullscreenenter) | The map switched to fullscreen mode. Instance of the [Event](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. ||
|| [fullscreenexit](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#event-fullscreenexit) | The map exited full-screen mode. Instance of the [Event](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class. ||
|| [mousedown](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mousedown) | Pressing the mouse button over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mousedown). ||
|| [mouseenter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mouseenter) | Pointing the cursor at the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mouseenter). ||
|| [mouseleave](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mouseleave) | Moving the cursor off of the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mouseleave). ||
|| [mousemove](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mousemove) | Moving the cursor over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mousemove). ||
|| [mouseup](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mouseup) | Letting go of the mouse button over an object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-mouseup). ||
|| [multitouchend](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-multitouchend) | End of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface.

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-multitouchend). ||
|| [multitouchmove](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-multitouchmove) | Repeating event during multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields: 
- clientX - X coordinate of the touch relative to the viewable area of the browser.
- clientY - Y coordinate of the touch relative to the viewable area of the browser.
- pageX - X coordinate of the touch relative to the beginning of the document.
- pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-multitouchmove). ||
|| [multitouchstart](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-multitouchstart) | Start of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields: 
- clientX - X coordinate of the touch relative to the viewable area of the browser.
- clientY - Y coordinate of the touch relative to the viewable area of the browser.
- pageX - X coordinate of the touch relative to the beginning of the document.
- pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from [IDomEventEmitter](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-multitouchstart). ||
|| [sizechange](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#event-sizechange) | Change to the size of the map container. 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: 
- oldSize: Number[];
- newSize: Number[];
- oldOffset: Number[];
- newOffset: Number[];
- preservePixelPosition: Boolean. ||
|| [wheel](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IDomEventEmitter.md#event-wheel) | Mouse wheel scrolling. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the [MapEvent](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent.md) class. More information is available in [domEvent.manager](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/domEvent.manager.md).

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

## Methods {#methods-summary}

#|
|| **Name** | **Returns** | **Description** ||
|| [enterFullscreen](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#enterFullscreen)() | | Allows you to switch the map to full-screen mode. ||
|| [exitFullscreen](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#exitFullscreen)() | | Allows you to take the map out of full-screen mode. ||
|| [fitToViewport](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#fitToViewport)(\[[preservePixelPosition](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#fitToViewport-param-preservePixelPosition)]) | | Called when the size of the map container is changed so that the map applies the new size. ||
|| [getElement](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#getElement)() | HTMLElement | Returns map HTML element. ||
|| [getOffset](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#getOffset)() | Number[] | Returns the shift of the map container in pixels, relative to the upper-left corner of the document. ||
|| [getParentElement](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#getParentElement)() | HTMLElement | Returns custom HTML element which contains the created map. ||
|| [getSize](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#getSize)() | Number[] | Returns size of the map container, in pixels. ||
|| [isFullscreen](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Container.md#isFullscreen)() | Boolean | Returns indicates whether the map is in full-screen mode. ||
|#

## Events details {#event_detail}

### beforefullscreenexit {#beforefullscreenexit}

The event preceding the "fullscreenexit" event. If the [Event.preventDefault](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md#preventDefault) method is called for this event, a subsequent fullscreenexit event will be canceled. Instance of the [Event](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class.

### fullscreenenter {#fullscreenenter}

The map switched to fullscreen mode. Instance of the [Event](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class.

### fullscreenexit {#fullscreenexit}

The map exited full-screen mode. Instance of the [Event](https://yandex.com.tr/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event.md) class.

### sizechange {#sizechange}

Change to the size of the map container. 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: 
- oldSize: Number[];
- newSize: Number[];
- oldOffset: Number[];
- newOffset: Number[];
- preservePixelPosition: Boolean.

## Methods details {#method_detail}

### enterFullscreen {#enterFullscreen}

```javascript
{} enterFullscreen()
```

Allows you to switch the map to full-screen mode.

### exitFullscreen {#exitFullscreen}

```javascript
{} exitFullscreen()
```

Allows you to take the map out of full-screen mode.

### fitToViewport {#fitToViewport}

```javascript
{} fitToViewport([preservePixelPosition])
```

Called when the size of the map container is changed so that the map applies the new size.

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`preservePixelPosition`](#fitToViewport-param-preservePixelPosition) | — | Type: Boolean

Save the location of the map center. ||
|#


**Example:**

```javascript
// Changing the dimensions of the map container
map.container.getElement().style.width = '300px';
// Initializing size recalculation
map.container.fitToViewport();
```

### getElement {#getElement}

```javascript
{HTMLElement} getElement()
```

**Returns** map HTML element.

### getOffset {#getOffset}

```javascript
{Number[]} getOffset()
```

**Returns** the shift of the map container in pixels, relative to the upper-left corner of the document.

### getParentElement {#getParentElement}

```javascript
{HTMLElement} getParentElement()
```

**Returns** custom HTML element which contains the created map.

### getSize {#getSize}

```javascript
{Number[]} getSize()
```

**Returns** size of the map container, in pixels.

### isFullscreen {#isFullscreen}

```javascript
{Boolean} isFullscreen()
```

**Returns** indicates whether the map is in full-screen mode.

[*star]: Mandatory parameter/option.