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

# Creating and deleting

<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-1/examples/2/out/s3-cases/en/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/plzknl?file=index.html">Open in CodeSandbox</a>

<div id="references">
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/ready">ready</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map">Map</a>
</div>
<p>
    The main component of the API is a map that can be placed
    in any block HTML element and always has a rectangular shape.
</p>
<p>
    To <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/dg/concepts/map#add_and_destroy">create a map</a>,
    use the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map">Map</a> class.
    In the constructor, specify the center, the zoom level,
    and the HTML element the map will be placed in.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>

    <html>
        <head>
            <meta
                http-equiv="Content-Type"
                content="text/html; charset=UTF-8"
            />
            <title>Examples. Putting the map on a page.</title>
            <!--
            Set your own API-key. Testing key is not valid for other web-sites and services.
            Get your API-key on the Developer Dashboard: https://developer.tech.yandex.ru/keys/
        -->
            
            
            
        </head>

        <body>
            <div id="map"></div>
            <input type="button" id="destroyButton" value="Delete map" />
        </body>
    </html>
    ```

-   mapbasics.js

    ```js
    var myMap;

    // Waiting for the API to load and DOM to be ready.
    ymaps.ready(init);

    function init() {
        /**
         * Creating an instance of the map and binding it to the container
         * with the specified ID ("map").
         */
        myMap = new ymaps.Map(
            "map",
            {
                /**
                 * When initializing the map, you must specify
                 * its center and the zoom factor.
                 */
                center: [55.76, 37.64], // Moscow
                zoom: 10,
            },
            {
                searchControlProvider: "yandex#search",
            }
        );

        document.getElementById("destroyButton").onclick = function () {
            // To destroy it, the "destroy" method is used.
            myMap.destroy();
        };
    }
    ```

{% endlist %}
