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

# Filling a polygon with the image

<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/polygon_with_image/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/f3mw3t?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/Polygon">Polygon</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/map.GeoObjects">map.GeoObjects</a>
</div>
<p>
    You can fill polygon, rectangle and circle with a background image. Specify a link to the background image in the <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObject-docpage/#param-options.fillImageHref">fillImageHref</a> option.
</p>
<p>
    Type of the background fill - <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObject-docpage/#param-options.fillMethod">fillMethod</a>. The option can take one of two values:
    <ul>
        <li>stretch - the background image stretches to fit the overlay.</li>
        <li>tile - the background image is repeated without changes in size.</li>
    </ul>
</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>Examples. Filling a polygon with the image.</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>
    ```

-   polygon_with_image.js

    ```js
    ymaps.ready(init);

    function init() {
        var myMap = new ymaps.Map(
            "map",
            {
                center: [60.179022977567406, 30.505805864880234],
                zoom: 12,
            },
            {
                searchControlProvider: "yandex#search",
            }
        );

        // Creating a polygon using the Polygon auxiliary class.
        var myPolygon = new ymaps.Polygon(
            [
                // Specifying the coordinates of the vertices of the polygon.
                [
                    [60.1918981644201, 30.513391151974343],
                    [60.190786978271895, 30.517596855709733],
                    [60.18411906873506, 30.52532161767263],
                    [60.17744980033012, 30.52789653832693],
                    [60.17505537249033, 30.526866570065202],
                    [60.16949620406973, 30.51313365990895],
                    [60.16744334943163, 30.512961998532003],
                    [60.16590362399728, 30.52034343774098],
                    [60.16325170493725, 30.518626823971463],
                    [60.161968441206376, 30.512790337155053],
                    [60.16094179402215, 30.513476982662866],
                    [60.1600006725024, 30.51055873925465],
                    [60.16136956759276, 30.5016323476531],
                    [60.16556145295854, 30.49922908837575],
                    [60.16992386592128, 30.50060237939137],
                    [60.171292346312335, 30.502147331783966],
                    [60.17257524473589, 30.50060237939137],
                    [60.17334495966222, 30.49734081322926],
                    [60.176167092910546, 30.481719627926545],
                    [60.17719326286712, 30.479659691403086],
                    [60.17787735830078, 30.474509850094513],
                    [60.181725128740176, 30.471248283932404],
                    [60.18198163068699, 30.468158379147237],
                    [60.18300761837183, 30.469531670162862],
                    [60.182409129464446, 30.47210659081716],
                    [60.18437555191994, 30.475368156979272],
                    [60.18574342829046, 30.479659691403086],
                    [60.18694027321249, 30.482921257565195],
                    [60.1886499757379, 30.48446620995779],
                    [60.189419312729555, 30.485496178219496],
                    [60.189846714352946, 30.48927272851247],
                    [60.1905305453375, 30.49098934228201],
                    [60.19155626501584, 30.4903026967742],
                    [60.192752897330365, 30.49665416772145],
                    [60.191043409196396, 30.5042072683074],
                    [60.19232553367115, 30.509185448239027],
                    [60.1918981644201, 30.513391151974343],
                ],
            ],
            // Defining properties of the geo object.
            {
                // The contents of the balloon.
                balloonContent: "Fishing spots",
            },
            {
                /**
                 * Describing the geo object options.
                 * Fill color.
                 */
                fillImageHref: "lake.svg",
                // Type of background fill.
                fillMethod: "stretch",
                // Hiding the stroke.
                stroke: false,
            }
        );

        // Adding the polygon to the map.
        myMap.geoObjects.add(myPolygon);
    }
    ```

{% endlist %}
