---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/examples/cases/mapbasics.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/llms.txt

# Создание и удаление

<iframe id="LIVE-EXAMPLE" style="width:100%;height: 400px;border-radius: 8px;border: 1px solid rgba(92, 94, 102, 0.14);" frameBorder="0" src="https://yastatic.net/s3/front-maps-static/maps-front-jsapi-v2-0/examples/1/out/s3-cases/ru/mapbasics/index.html" allow="fullscreen"></iframe>

<a target="_blank" rel="noopener noreferrer" style="display: inline-block;margin-top: 10px;cursor: pointer;border-radius: 4px;padding: 9px 12px;background: #151515;color: white;text-decoration: none;font-weight: 500" href="https://codesandbox.io/p/sandbox/mzfgpy?file=index.html">Open in CodeSandbox</a>

<div id="doc">
<div id="references">
    <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/ref/reference/ready">ready</a>,
    <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/ref/reference/Map">Map</a>
</div>
<p>
    Основным компонентом API является карта, которая может быть размещена
    в любом блочном HTML-элементе и всегда имеет прямоугольную форму.
</p>
<p>
    Для <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/dg/concepts/map#add_and_destroy">создания карты</a>
    предназначен класс <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/ref/reference/Map">Map</a>.
    В конструкторе необходимо указать центр, коэффициент масштабирования
    и HTML-элемент, в котором будет размещена карта.
</p>
</div>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>

    <html>
        <head>
            <meta
                http-equiv="Content-Type"
                content="text/html; charset=utf-8"
            />
            <title>Примеры. Размещение карты на странице.</title>
            <!--
            Подключаем API карт
            Параметры:
              - load=package.standard - основные компоненты;
    	      - lang=ru-RU - язык русский.
        -->
            <!--
            Укажите свой API-ключ. Тестовый ключ НЕ БУДЕТ работать на других сайтах.
            Получить ключ можно в Кабинете разработчика: https://developer.tech.yandex.ru/keys/
        -->
            

            
        </head>

        <body>
            <div id="map" style="width:400px; height:300px"></div>
            <input type="button" id="destroyButton" value="Удалить карту" />
        </body>
    </html>
    ```

-   mapbasics.js

    ```js
    var myMap;

    // Дождёмся загрузки API и готовности DOM.
    ymaps.ready(init);

    function init() {
        // Создание экземпляра карты и его привязка к контейнеру с
        // заданным id ("map").
        myMap = new ymaps.Map("map", {
            // При инициализации карты обязательно нужно указать
            // её центр и коэффициент масштабирования.
            center: [55.76, 37.64], // Москва
            zoom: 10,
        });

        document.getElementById("destroyButton").onclick = function () {
            // Для уничтожения используется метод destroy.
            myMap.destroy();
        };
    }
    ```

{% endlist %}
