Skip to content

Instantly share code, notes, and snippets.

@tst32
Forked from ktokot/ymaps.js
Created January 20, 2021 10:48
Show Gist options
  • Save tst32/992bc9fbd7d3ddce1141ab56b5eec788 to your computer and use it in GitHub Desktop.
Save tst32/992bc9fbd7d3ddce1141ab56b5eec788 to your computer and use it in GitHub Desktop.
code for yandex maps
ymaps.ready(function () {
var myMap = new ymaps.Map('map', {
center: [55.751574, 37.573856],
zoom: 9
}, {
searchControlProvider: 'yandex#search'
}),
// Создаём макет содержимого.
MyIconContentLayout = ymaps.templateLayoutFactory.createClass(
'<div style="color: #FFFFFF; font-weight: bold;">$[properties.iconContent]</div>'
),
myPlacemark = new ymaps.Placemark(myMap.getCenter(), {
hintContent: 'Собственный значок метки',
balloonContent: 'Это красивая метка' }, {
// Опции.
// Необходимо указать данный тип макета.
iconLayout: 'default#image',
// Своё изображение иконки метки.
iconImageHref: 'images/myIcon.gif',
// Размеры метки.
iconImageSize: [30, 42],
// Смещение левого верхнего угла иконки относительно
// её "ножки" (точки привязки).
iconImageOffset: [-5, -38]
}),
myPlacemarkWithContent = new ymaps.Placemark([55.661574, 37.573856], {
hintContent: 'Собственный значок метки с контентом',
balloonContent: 'А эта — новогодняя',
iconContent: '12'
}, {
// Опции.
// Необходимо указать данный тип макета.
iconLayout: 'default#imageWithContent',
// Своё изображение иконки метки.
iconImageHref: 'images/ball.png',
// Размеры метки.
iconImageSize: [48, 48],
// Смещение левого верхнего угла иконки относительно
// её "ножки" (точки привязки).
iconImageOffset: [-24, -24],
// Смещение слоя с содержимым относительно слоя с картинкой.
iconContentOffset: [15, 15],
// Макет содержимого.
iconContentLayout: MyIconContentLayout
});
myMap.geoObjects
.add(myPlacemark)
});
@tst32
Copy link
Author

tst32 commented Jul 31, 2021

Screenshot_20210731-140112~2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment