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

# Setting a hotspot shape of the HTML layout of the placemark

<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/placemark_shape/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/grsr7v?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/Placemark">Placemark</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/templateLayoutFactory">templateLayoutFactory</a>
</div>
    This example creates three placemarks with their own HTML layouts. <br/>
    Custom layouts are created using the layout factory. <br/>
    All the placemarks have different hotspot shapes set: rectangle, circle, or polygon. <br/><br/>
    In order to catch mouse events, the layout uses a <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/dg/concepts/about-hotspots">hotspot</a>. <br/>
    By default, the hotspot shape isn't set when creating your own HTML layout, and you need to set it yourself.<br/>
    You can do this using the 'iconShape' layout option as a <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IGeometryJson">JSON description of a geometry</a>.

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>
                Example of setting custom HTML layouts for placemarks with your
                own hotspot shapes
            </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>
    ```

-   placemark_shape.js

    ```js
    ymaps.ready(function () {
        var map = new ymaps.Map("map", {
            center: [55.7, 37.6],
            zoom: 10,
            controls: [],
        });

        // Creating a placemark with a square hotspot.
        var squareLayout = ymaps.templateLayoutFactory.createClass(
            '<div class="placemark_layout_container"><div class="square_layout">$</div></div>'
        );

        var squarePlacemark = new ymaps.Placemark(
            [55.725118, 37.682145],
            {
                hintContent: "Placemark with a rectangular HTML layout",
            },
            {
                iconLayout: squareLayout,
                // Describing the shape of a "Rectangle" hotspot.
                iconShape: {
                    type: "Rectangle",
                    // The rectangle is defined as two points: the upper left and lower right.
                    coordinates: [
                        [-25, -25],
                        [25, 25],
                    ],
                },
            }
        );
        map.geoObjects.add(squarePlacemark);

        // Creating a placemark with a round hotspot.
        var circleLayout = ymaps.templateLayoutFactory.createClass(
            '<div class="placemark_layout_container"><div class="circle_layout">#</div></div>'
        );

        var circlePlacemark = new ymaps.Placemark(
            [55.783202, 37.605584],
            {
                hintContent: "Placemark with a circular HTML layout",
            },
            {
                iconLayout: circleLayout,
                // Describing the shape of a "Circle" hotspot.
                iconShape: {
                    type: "Circle",
                    // The circle is defined as the center and radius
                    coordinates: [0, 0],
                    radius: 25,
                },
            }
        );
        map.geoObjects.add(circlePlacemark);

        // Creating a placemark with a complex hotspot shape.
        var polygonLayout = ymaps.templateLayoutFactory.createClass(
            '<div class="placemark_layout_container"><div class="polygon_layout">!</div></div>'
        );

        var polygonPlacemark = new ymaps.Placemark(
            [55.662693, 37.558416],
            {
                hintContent: "HTML placemark with a complex shape",
            },
            {
                iconLayout: polygonLayout,
                // Describing the shape of a "Polygon" hotspot.
                iconShape: {
                    type: "Polygon",
                    /**
                     * A polygon is defined as a three-dimensional array. The top-level array contains the contours of the polygon.
                     * The first element of the array is the external contour, and the others are internal contours.
                     */
                    coordinates: [
                        // Describing the external polygon contour as an array of coordinates.
                        [
                            [-28, -76],
                            [28, -76],
                            [28, -20],
                            [12, -20],
                            [0, -4],
                            [-12, -20],
                            [-28, -20],
                        ],
                        // ,... Describing the internal contours - empty areas inside the external contour.
                    ],
                },
            }
        );
        map.geoObjects.add(polygonPlacemark);
    });
    ```

{% endlist %}
