Skip to content

Instantly share code, notes, and snippets.

@SashaKolbasov
Last active July 19, 2017 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SashaKolbasov/de8a388b4be62f6d62a80a458e885fc4 to your computer and use it in GitHub Desktop.
Save SashaKolbasov/de8a388b4be62f6d62a80a458e885fc4 to your computer and use it in GitHub Desktop.
Yandex Placemark
<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