---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/examples/cases/polyline.md
  - https://yandex.com/dev/jsapi-v2-1/doc/ru/v2-1/examples/cases/polyline.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/jsapi-v2-1/doc/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-1/examples/2/out/s3-cases/ru/polyline/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/fhj9dq?file=index.html">Open in CodeSandbox</a>

<div id="references">
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/ready">ready</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/Map">Map</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/GeoObject">GeoObject</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/Polyline">Polyline</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/map.GeoObjects">map.GeoObjects</a>
</div>
<p>
    Ломаная - это фигура, состоящая из набора последовательно соединённых вершин. Ломаная может иметь самопересечения.
</p>
<p>
    Ломаные могут быть созданы двумя способами: с помощью класса
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/dg/concepts/geoobjects">GeoObject</a> с указанием типа геометрии "Ломаная линия"
    либо с помощью вспомогательного класса <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/dg/concepts/geoobjects#geometry">Polyline</a>.
</p>
<p>
    При создании ломаной ей могут быть заданы <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/GeoObject#constructor-summary">свойства</a> (например содержимое балуна или хинта) и <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/GeoObject#constructor-summary">опции</a> (например: цвет, толщину).
</p>
<p>
    Ломаные, наряду с другими геообъектами, можно объединять в <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/dg/concepts/geoobjects#geoobject_collections">коллекции</a>.
</p>

{% 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"></div>
        </body>
    </html>
    ```

-   polyline.js

    ```js
    ymaps.ready(init);

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

        // Создаем ломаную, используя класс GeoObject.
        var myGeoObject = new ymaps.GeoObject(
            {
                // Описываем геометрию геообъекта.
                geometry: {
                    // Тип геометрии - "Ломаная линия".
                    type: "LineString",
                    // Указываем координаты вершин ломаной.
                    coordinates: [
                        [55.8, 37.5],
                        [55.7, 37.4],
                    ],
                },
                // Описываем свойства геообъекта.
                properties: {
                    // Содержимое хинта.
                    hintContent: "Я геообъект",
                    // Содержимое балуна.
                    balloonContent: "Меня можно перетащить",
                },
            },
            {
                // Задаем опции геообъекта.
                // Включаем возможность перетаскивания ломаной.
                draggable: true,
                // Цвет линии.
                strokeColor: "#FFFF00",
                // Ширина линии.
                strokeWidth: 5,
            }
        );

        // Создаем ломаную с помощью вспомогательного класса Polyline.
        var myPolyline = new ymaps.Polyline(
            [
                // Указываем координаты вершин ломаной.
                [55.8, 37.5],
                [55.8, 37.4],
                [55.7, 37.5],
                [55.7, 37.4],
            ],
            {
                // Описываем свойства геообъекта.
                // Содержимое балуна.
                balloonContent: "Ломаная линия",
            },
            {
                // Задаем опции геообъекта.
                // Отключаем кнопку закрытия балуна.
                balloonCloseButton: false,
                // Цвет линии.
                strokeColor: "#000000",
                // Ширина линии.
                strokeWidth: 4,
                // Коэффициент прозрачности.
                strokeOpacity: 0.5,
            }
        );

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

{% endlist %}
