G
G
gimlen2020-07-24 13:26:37
css
gimlen, 2020-07-24 13:26:37

How to make an interactive map for the site, but with a changed icon in place of the label?

The task is to make an interactive map for the site, but in the place where the mark (marker) should be, you need to put a custom icon.5f1ab7554983e960502334.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
display: block, 2020-07-24
@gimlen

https://tech.yandex.ru/maps/jsbox/2.1/icon_customImage

M
mahmudchon, 2020-07-24
@mahmudchon

The code is very short and not complicated.

ymaps.ready(function () {

    var myMap = new ymaps.Map('map', {
            center: [55.751574, 37.573856],
            zoom: 10
        }, {
            searchControlProvider: 'yandex#search'
        }),

        myPlacemark = new ymaps.Placemark([55.661574, 37.573856], {
            hintContent: 'Подсказка',
            balloonContent: 'Содержание'
        }, {
            // Опции.
            // Необходимо указать данный тип макета.
            iconLayout: 'default#image',
            // Своё изображение иконки метки.
            iconImageHref: 'marker.png',
            // Размеры метки.
            iconImageSize: [20, 28],
            // Смещение левого верхнего угла иконки относительно
            // её "ножки" (точки привязки).
            iconImageOffset: [-10, -28]
        });

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question