Last active
July 19, 2017 16:45
-
-
Save SashaKolbasov/de8a388b4be62f6d62a80a458e885fc4 to your computer and use it in GitHub Desktop.
Yandex Placemark
This file contains 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
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> | |
<a class="mapFly" data-flyx="59.9178326" data-flyy="30.3937128">Санкт-петербург</a> | |
<a class="mapFly" data-flyx="55.755826" data-flyy="37.6173">Москва</a> | |
<script type="text/javascript"> | |
ymaps.ready(init); | |
function init() { | |
var myMap = new ymaps.Map('map', { | |
center: [59.9178326, 30.3937128], | |
zoom: 16 | |
}); | |
var mark1 = new ymaps.Placemark( | |
[59.9178326, 30.3937128], {}, { | |
iconLayout: 'default#image', | |
iconImageHref: '../img/icons/icon-marker.png', | |
iconImageSize: [94, 104], | |
iconImageOffset: [-40, -83], | |
}); | |
var mark2 = new ymaps.Placemark( | |
[55.755826, 37.6173], {}, { | |
iconLayout: 'default#image', | |
iconImageHref: '../img/icons/icon-marker.png', | |
iconImageSize: [94, 104], | |
iconImageOffset: [-40, -83], | |
}); | |
myMap.geoObjects.add(mark1); | |
myMap.geoObjects.add(mark2); | |
myMap.controls.remove('geolocationControl'); | |
myMap.controls.remove('searchControl'); | |
myMap.controls.remove('trafficControl'); | |
myMap.controls.remove('typeSelector'); | |
myMap.controls.remove('fullscreenControl'); | |
myMap.controls.remove('zoomControl'); | |
myMap.controls.remove('rulerControl'); | |
// flyMap | |
$('.mapFly').on('click', function() { | |
var x = $(this).data('flyx'), | |
y = $(this).data('flyy'); | |
console.log(x, y); | |
myMap.panTo( | |
[x, y], { | |
flying: true | |
} | |
); | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment