---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com.tr/dev/jsapi-v2-1/doc/ru/v2-1/examples/cases/mapsapi-area.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com.tr/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/mapsapi-area/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/4sl9ld?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/Placemark">Placemark</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/map.GeoObjects">map.GeoObjects</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/Polygon">Polygon</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/geometryEditor.Polygon">geometryEditor.Polygon</a>
</div>
<p>
    Пример использования <a href="https://github.com/yandex/mapsapi-area">плагина для расчета площади</a>.
</p>
<p>
    Модуль позволяет рассчитать площадь полигонов, прямоугольников и кругов. Обратите внимание, что плагин работает только с геодезическими геометриями.
    Для использования плагина необходимо подключить <a href="https://github.com/yandex/mapsapi-area/">util.calculateArea</a>.
</p>
<p>
    <a href="https://github.com/yandex/mapsapi-area">Подробная документация</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>
    ```

-   mapsapi-area.js

    ```js
    // Обратите внимание, что модуль не умеет обсчитывать полигоны с самопересечениями.
    ymaps.ready(["util.calculateArea"]).then(function () {
        var myMap = new ymaps.Map(
                "map",
                {
                    center: [55.9238145091058, 37.897131347654376],
                    zoom: 10,
                    controls: ["searchControl", "zoomControl"],
                },
                {
                    searchControlProvider: "yandex#search",
                }
            ),
            // Создаем многоугольник, круг и прямоугольник.
            polygon = new ymaps.GeoObject({
                geometry: {
                    type: "Polygon",
                    coordinates: [
                        [
                            [55.97544201439153, 37.71984863281182],
                            [55.876808118310706, 37.66697692871001],
                            [55.8748378377763, 37.78258361816322],
                            [55.97544201439153, 37.71984863281182],
                        ],
                    ],
                },
            }),
            circle = new ymaps.Circle([
                [55.9238145091058, 38.097131347654376],
                5000,
            ]),
            rectangle = new ymaps.Rectangle([
                [55.973805634187, 37.81389007567776],
                [55.87510965298843, 37.95396575927215],
            ]),
            collection = new ymaps.GeoObjectCollection();
        // Добавляем геообъекты в коллекцию.
        collection.add(polygon).add(circle).add(rectangle);
        // Добавляем коллекцию на карту.
        myMap.geoObjects.add(collection);

        collection.each(function (obj) {
            // Вычисляем площадь геообъекта.
            var area = Math.round(ymaps.util.calculateArea(obj)),
                // Вычисляем центр для добавления метки.
                center = ymaps.util.bounds.getCenter(obj.geometry.getBounds());
            // Если площадь превышает 1 000 000 м², то приводим ее к км².
            if (area <= 1e6) {
                area += " м²";
            } else {
                area = (area / 1e6).toFixed(3) + " км²";
            }
            obj.properties.set("balloonContent", area);

            myMap.geoObjects.add(
                new ymaps.Placemark(
                    center,
                    { iconCaption: area },
                    { preset: "islands#greenDotIconWithCaption" }
                )
            );
        });
    });
    ```

{% endlist %}
