Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- // (function(){
- // ymaps.ready(function(){ return false })
- // })();
- //
- $("body").append($("<script src='https://api-maps.yandex.ru/2.1/?apikey=79f805ba-580b-439f-9732-29bf1074af7d&lang=ru_RU'></script>"));
- let yMapsIsShown = false;
- let myMap;
- $(window).scroll(function() {
- if(!yMapsIsShown) {
- if ($(window).height() + $(window).scrollTop() > $(".b-map").offset().top) {
- yMapsIsShown = true;
- ymaps.ready(init);
- function init(){
- console.log("map init")
- myMap = new ymaps.Map ("map", {
- center: [55.76, 37.64],
- zoom: 7
- });
- // Создаём макет содержимого.
- MyIconContentLayout = ymaps.templateLayoutFactory.createClass(
- '<div style="color: #FFFFFF; font-weight: bold;">$[properties.iconContent]</div>'
- ),
- myPlacemark = new ymaps.Placemark([55.661574, 37.573856], {
- hintContent: 'Собственный значок метки 1',
- balloonContent: 'baloon text 1'
- }, {
- // Опции.
- // Необходимо указать данный тип макета.
- iconLayout: 'default#image',
- // Своё изображение иконки метки.
- // iconImageHref: 'images/myIcon.gif',
- // Размеры метки.
- // iconImageSize: [30, 42],
- // Смещение левого верхнего угла иконки относительно
- // её "ножки" (точки привязки).
- iconImageOffset: [-5, -38]
- }),
- myPlacemarkWithContent = new ymaps.Placemark([55.661574, 37.573856], {
- hintContent: 'Собственный значок метки 2',
- balloonContent: 'baloon text 2',
- }, {
- // Опции.
- // Необходимо указать данный тип макета.
- iconLayout: 'default#imageWithContent',
- // Своё изображение иконки метки.
- // iconImageHref: 'images/ball.png',
- // Размеры метки.
- // iconImageSize: [48, 48],
- // Смещение левого верхнего угла иконки относительно
- // её "ножки" (точки привязки).
- iconImageOffset: [-24, -24],
- // Смещение слоя с содержимым относительно слоя с картинкой.
- iconContentOffset: [15, 15],
- // Макет содержимого.
- iconContentLayout: MyIconContentLayout
- });
- myMap.geoObjects
- .add(myPlacemark)
- .add(myPlacemarkWithContent);
- }
- }
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement