Last active
March 21, 2018 23:52
-
-
Save zogreptile/6aeac008c2ff17e22245c6e5ec5b7865 to your computer and use it in GitHub Desktop.
Несколько объектов на яндекс карте. Позиционирование метки.
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
ymaps.ready(init); | |
var myMap, | |
myPlacemark; | |
var places = [ | |
{ | |
name: 'Точка № 1', | |
lat: 48.471125, | |
long: 135.058703 | |
}, | |
{ | |
name: 'Точка № 2', | |
lat: 48.483765, | |
long: 135.093890 | |
} | |
]; | |
function init() { | |
myMap = new ymaps.Map("map", { | |
center: [48.485974, 135.108155], | |
zoom: 14 | |
}); | |
for (var i = 0; i < places.length; i++) { | |
var myPlacemark = new ymaps.Placemark([places[i].lat, places[i].long], { | |
hintContent: places[i].name, | |
// balloonContent: '' | |
}, { | |
iconLayout: 'default#image', | |
iconImageHref: 'img/map.png', | |
iconImageSize: [80, 80], | |
// Смещение левого верхнего угла иконки относительно | |
// её "ножки" (точки привязки). | |
iconImageOffset: [0, -80] | |
}); | |
myMap.geoObjects.add(myPlacemark); | |
} | |
var allPoints = ymaps.geoQuery(myMap.geoObjects); | |
myMap.setBounds(allPoints.getBounds(), { checkZoomRange: true }); | |
myMap.behaviors.disable('scrollZoom'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment