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

# Event properties. Click coordinates

<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/event_properties/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/jhvg8l?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/map.Balloon">map.Balloon</a>, <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.Hint">map.Hint</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent">MapEvent</a>
</div>
<p>
    A map event is an object of the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/MapEvent">MapEvent</a> class.
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/dg/concepts/events#event_object">Data is extracted
    from this object </a> using the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event#get">get</a> method.
</p>
<p>
    In this example, the coordinates of the point clicked with the left mouse button are extracted from the event object.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>Examples. Click coordinates</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>
            <div id="map"></div>
        </body>
    </html>
    ```

-   event_properties.js

    ```js
    ymaps.ready(init);
    var myMap;

    function init() {
        myMap = new ymaps.Map(
            "map",
            {
                center: [57.5262, 38.3061], // Uglich
                zoom: 11,
            },
            {
                balloonMaxWidth: 200,
                searchControlProvider: "yandex#search",
            }
        );

        /**
         * Processing events that occur when the user
         * left-clicks anywhere on the map.
         * When such an event occurs, we open the balloon.
         */
        myMap.events.add("click", function (e) {
            if (!myMap.balloon.isOpen()) {
                var coords = e.get("coords");
                myMap.balloon.open(coords, {
                    contentHeader: "Event!",
                    contentBody:
                        "<p>Someone clicked on the map.</p>" +
                        "<p>Click coordinates: " +
                        [
                            coords[0].toPrecision(6),
                            coords[1].toPrecision(6),
                        ].join(", ") +
                        "</p>",
                    contentFooter: "<sup>Click again</sup>",
                });
            } else {
                myMap.balloon.close();
            }
        });

        /**
         * Processing events that occur when the user
         * right-clicks anywhere on the map.
         * When such an event occurs, we display a popup hint
         * at the point of click.
         */
        myMap.events.add("contextmenu", function (e) {
            myMap.hint.open(e.get("coords"), "Someone right-clicked");
        });

        // Hiding the hint when opening the balloon.
        myMap.events.add("balloonopen", function (e) {
            myMap.hint.close();
        });
    }
    ```

{% endlist %}
