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

# Setting a custom placemark 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/icon_customImage/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/snhh22?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/Placemark">Placemark</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/layout.Image">layout.Image</a>,
    <a href="https://yandex.ru/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/layout.ImageWithContent">layout.ImageWithContent</a>
</div>
<p>
    The API provides the ability to set custom images for placemarks.
</p>
<p>
    To set a desired image, specify the following options for the placemark:
    <ul>
        <li>iconLayout: "default#image";</li>
        <li>iconImageHref: {URL of the graphic file}.</li>
    </ul>
</p>
<p>
    To set the image with the content specify the following placemark options:
<ul>
    <li>iconLayout: "default#imageWithContent";</li>
    <li>iconImageHref: {URL of the graphic file}.</li>
</ul>
    And also specify the content of the geo object icon:
<ul>
    <li>iconContent: 'content';</li>
</ul>
</p>
<p>
    You can also set the options iconImageSize (width and height of the image in pixels), iconImageOffset (the offset of the icon's upper-left corner relative to the anchor point),  iconImageClipRect (coordinates of the displayed area of the source image, in pixels), iconContentOffset (the offset of the text relative to the placemark's anchor point) and iconContentLayout (content layout).

</p>

{% list tabs %}

-   index.html

    ```html
    <!DOCTYPE html>
    <html>
        <head>
            <title>Examples. Setting a custom placemark 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>
    ```

-   icon_customImage.js

    ```js
    ymaps.ready(function () {
        var myMap = new ymaps.Map(
                "map",
                {
                    center: [55.751574, 37.573856],
                    zoom: 9,
                },
                {
                    searchControlProvider: "yandex#search",
                }
            ),
            // Creating a content layout.
            MyIconContentLayout = ymaps.templateLayoutFactory.createClass(
                '<div style="color: #FFFFFF; font-weight: bold;">$[properties.iconContent]</div>'
            ),
            myPlacemark = new ymaps.Placemark(
                myMap.getCenter(),
                {
                    hintContent: "A custom placemark icon",
                    balloonContent: "This is a pretty placemark",
                },
                {
                    /**
                     * Options.
                     * You must specify this type of layout.
                     */
                    iconLayout: "default#image",
                    // Custom image for the placemark icon.
                    iconImageHref: "icons/pin.svg",
                    // The size of the placemark.
                    iconImageSize: [48, 48],
                    /**
                     * The offset of the upper left corner of the icon relative
                     * to its "tail" (the anchor point).
                     */
                    iconImageOffset: [-5, -44],
                }
            ),
            myPlacemarkWithContent = new ymaps.Placemark(
                [55.661574, 37.573856],
                {
                    hintContent: "A custom placemark icon with contents",
                    balloonContent: "This one — for Christmas",
                    iconContent: "12",
                },
                {
                    /**
                     * Options.
                     * You must specify this type of layout.
                     */
                    iconLayout: "default#imageWithContent",
                    // Custom image for the placemark icon.
                    iconImageHref: "icons/christmass-head.svg",
                    // The size of the placemark.
                    iconImageSize: [48, 48],
                    /**
                     * The offset of the upper left corner of the icon relative
                     * to its "tail" (the anchor point).
                     */
                    iconImageOffset: [-24, -24],
                    // Offset of the layer with content relative to the layer with the image.
                    iconContentOffset: [15, 15],
                    // Content layout.
                    iconContentLayout: MyIconContentLayout,
                }
            );

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

{% endlist %}
