Created
January 20, 2021 10:46
-
-
Save ktokot/5b2dd812a8e3573b57f691232348e7cf to your computer and use it in GitHub Desktop.
code for yandex maps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment