---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/examples/cases/polylineEditor.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/polylineEditor/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/6qfkjq?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>,
    <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/ref/reference/Polyline">Polyline</a>,
    <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/ref/reference/map.GeoObjects">map.GeoObjects</a>,
    <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/ref/reference/geometryEditor.LineString">geometryEditor.LineString</a>
</div>
<p>
    Для ломаных доступен <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/dg/concepts/geoobjects#visual_editing">визуальный редактор</a>. Ссылка на редактор содержится в поле <a href="https://yandex.ru/dev/maps/archive/doc/jsapi/2-0/ru/ref/reference/GeoObject#editor">editor</a> объекта-ломаной.
</p>
</div>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>

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

            
        </head>

        <body>
            <div id="map" style="width:400px; height:300px"></div>
        </body>
    </html>
    ```

-   polylineEditor.js

    ```js
    ymaps.ready(init);

    function init() {
        // Создаем карту.
        var myMap = new ymaps.Map("map", {
            center: [55.72, 37.64],
            zoom: 10,
        });

        // Создаем ломаную.
        var myPolyline = new ymaps.Polyline(
            [
                // Указываем координаты вершин.
                [55.8, 37.5],
                [55.8, 37.4],
                [55.7, 37.5],
                [55.7, 37.4],
            ],
            {},
            {
                // Задаем опции геообъекта.
                // Цвет с прозрачностью.
                strokeColor: "#00000088",
                // Ширину линии.
                strokeWidth: 4,
                // Максимально допустимое количество вершин в ломаной.
                editorMaxPoints: 6,
                // Добавляем в контекстное меню новый пункт, позволяющий удалить ломаную.
                editorMenuManager: function (items) {
                    items.push({
                        title: "Удалить линию",
                        onClick: function () {
                            myMap.geoObjects.remove(myPolyline);
                        },
                    });
                    return items;
                },
            }
        );

        // Добавляем линию на карту.
        myMap.geoObjects.add(myPolyline);

        // Включаем режим редактирования.
        myPolyline.editor.startEditing();
    }
    ```

{% endlist %}
