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

# Polygon editor

<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/polygonEditor/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/szxq42?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>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Polygon">Polygon</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects">map.GeoObjects</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geometryEditor.Polygon">geometryEditor.Polygon</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Monitor">Monitor</a>
</div>
<p>
    A <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/dg/concepts/geoobjects#visual_editing">visual editor</a> is available for polygons. A link to the editor is in the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObject#editor">editor</a> field of the polygon object.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>Examples. Polygon editor</title>
            <meta
                http-equiv="Content-Type"
                content="text/html; charset=UTF-8"
            />
            <!--
            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>
            <p class="header">Click on the map to start creating a polygon</p>
            <div id="map"></div>
        </body>
    </html>
    ```

-   polygonEditor.js

    ```js
    ymaps.ready(init);

    function init() {
        var myMap = new ymaps.Map(
            "map",
            {
                center: [55.73, 37.75],
                zoom: 10,
            },
            {
                searchControlProvider: "yandex#search",
            }
        );

        // Creating a polygon with no vertices.
        var myPolygon = new ymaps.Polygon(
            [],
            {},
            {
                // The cursor in the mode for adding new vertices.
                editorDrawingCursor: "crosshair",
                // The maximum number of vertices.
                editorMaxPoints: 5,
                // Fill color.
                fillColor: "#00FF00",
                // Stroke color.
                strokeColor: "#0000FF",
                // The stroke width.
                strokeWidth: 5,
            }
        );
        // Adding the polygon to the map.
        myMap.geoObjects.add(myPolygon);

        // In the mode for adding new vertices, we change the stroke color of the polygon.
        var stateMonitor = new ymaps.Monitor(myPolygon.editor.state);
        stateMonitor.add("drawing", function (newValue) {
            myPolygon.options.set(
                "strokeColor",
                newValue ? "#FF0000" : "#0000FF"
            );
        });

        // Turning on the edit mode with the possibility of adding new vertices.
        myPolygon.editor.startDrawing();
    }
    ```

{% endlist %}
