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

# Changing the placemark settings

<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/geoobject_contextmenu/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/jtnjzz?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.container">Map.container</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Map.GeoObjects">Map.GeoObjects</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Placemark">Placemark</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/Event">Event</a>
</div>
<p>
    In this example, a geo object event is processed - a right-click on a placemark,
	which opens the context menu for managing the object's properties.
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>Examples. Geo object context menu</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>
            <p class="header">Open the context menu on a placemark</p>
            <div id="map"></div>
        </body>
    </html>
    ```

-   geoobject_contextmenu.js

    ```js
    ymaps.ready(init);

    function init() {
        // Creating the map.
        var myMap = new ymaps.Map(
            "map",
            {
                center: [47.6, 41.8],
                zoom: 9,
            },
            {
                searchControlProvider: "yandex#search",
            }
        );

        // Creating a placemark.
        var myPlacemark = new ymaps.Placemark(
            [47.6, 42.1],
            {
                iconContent: "Right-click me!",
            },
            {
                // Red icon that stretches to fit content.
                preset: "islands#redStretchyIcon",
            }
        );

        /**
         * The context menu allows you to change the placemark settings.
         * It is opened by right-clicking the placemark.
         */
        myPlacemark.events.add("contextmenu", function (e) {
            // If the placemark menu is already displayed, remove it.
            if ($("#menu").css("display") == "block") {
                $("#menu").remove();
            } else {
                // HTML content of the context menu.
                var menuContent =
                    '<div id="menu">\
                        <ul id="menu_list">\
                            <li>Name: <br /> <input type="text" name="icon_text" /></li>\
                            <li>Hint: <br /> <input type="text" name="hint_text" /></li>\
                            <li>Balloon: <br /> <input type="text" name="balloon_text" /></li>\
                        </ul>\
                    <div align="center"><input type="submit" value="Save" /></div>\
                    </div> ';

                // Putting a context menu on the page
                $("body").append(menuContent);

                // Setting the menu position.
                $("#menu").css({
                    left: e.get("pagePixels")[0],
                    top: e.get("pagePixels")[1],
                });

                // Filling the fields of the context menu with the current values of the placemark properties.
                $('#menu input[name="icon_text"]').val(
                    myPlacemark.properties.get("iconContent")
                );
                $('#menu input[name="hint_text"]').val(
                    myPlacemark.properties.get("hintContent")
                );
                $('#menu input[name="balloon_text"]').val(
                    myPlacemark.properties.get("balloonContent")
                );

                /**
                 * When the "Save" button is clicked, we change placemark properties
                 * to the values entered in the context menu form.
                 */
                $('#menu input[type="submit"]').click(function () {
                    myPlacemark.properties.set({
                        iconContent: $('input[name="icon_text"]').val(),
                        hintContent: $('input[name="hint_text"]').val(),
                        balloonContent: $('input[name="balloon_text"]').val(),
                    });
                    // Removing the context menu.
                    $("#menu").remove();
                });
            }
        });

        myMap.geoObjects.add(myPlacemark);
    }
    ```

{% endlist %}
