---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/examples/cases/geoobject_events.md
  - https://yandex.com/dev/jsapi-v2-1/doc/ru/v2-1/examples/cases/geoobject_events.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/geoobject_events/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/xhj8nl?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/Circle">Circle</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/Hint">Hint</a>
</div>
<p>
    В этом примере слушаются некоторые события геообъекта, и при их наступлении обновляется содержимое текстового поля.
    Полный список событий можно изучить в документации к классу <a href="https://yandex.ru/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/GeoObject#events-summary">GeoObject</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>
            <div id="log"></div>
        </body>
    </html>
    ```

-   geoobject_events.js

    ```js
    ymaps.ready(init);

    function init() {
        var log = document.getElementById("log"),
            myMap = new ymaps.Map("map", {
                center: [48.856929, 2.341198],
                zoom: 1,
                controls: ["zoomControl"],
            }),
            myCircle = new ymaps.Circle(
                [myMap.getCenter(), 1000000],
                {
                    balloonContentBody: "Балун",
                    hintContent: "Хинт",
                },
                {
                    draggable: true,
                }
            );

        myCircle.events.add(
            [
                "mapchange",
                "geometrychange",
                "pixelgeometrychange",
                "optionschange",
                "propertieschange",
                "balloonopen",
                "balloonclose",
                "hintopen",
                "hintclose",
                "dragstart",
                "dragend",
            ],
            function (e) {
                log.innerHTML = "@" + e.get("type") + "<br/>" + log.innerHTML;
            }
        );

        myMap.geoObjects.add(myCircle);

        setupControls(myMap, myCircle);
    }

    function setupControls(map, geoObject) {
        var btnProperty = new ymaps.control.Button("Свойство: balloonHeader"),
            btnOption = new ymaps.control.Button("Опция: geodesic"),
            btnRadius = new ymaps.control.Button("Изменить радиус");

        btnProperty.options.set("maxWidth", 200);
        btnOption.options.set("maxWidth", 200);
        btnRadius.options.set("maxWidth", 200);

        btnProperty.events.add(["select", "deselect"], function (e) {
            geoObject.properties.set(
                "balloonContentHeader",
                e.get("type") == "select" ? "Заголовок" : undefined
            );
        });
        btnOption.events.add(["select", "deselect"], function (e) {
            geoObject.options.set("geodesic", e.get("type") == "select");
        });
        btnRadius.events.add(["select", "deselect"], function (e) {
            geoObject.geometry.setRadius(
                e.get("type") == "select" ? 2000000 : 1000000
            );
        });

        map.controls.add(btnProperty).add(btnOption).add(btnRadius);
    }
    ```

{% endlist %}
