Skip to content

Instantly share code, notes, and snippets.

@seredniy
Created August 14, 2016 14:34
Show Gist options
  • Save seredniy/a1c52c4eab0299a6038fffa334b46fe0 to your computer and use it in GitHub Desktop.
Save seredniy/a1c52c4eab0299a6038fffa334b46fe0 to your computer and use it in GitHub Desktop.
Яндекс-карта с несколькими балунами
<script src="http://api-maps.yandex.ru/2.1/?lang=ru-RU" type="text/javascript"></script>
<script>
ymaps.ready(init);
function init () {
var myMap = new ymaps.Map('map', {
center: [55.83, 37.41],
zoom: 10
}, {
searchControlProvider: 'yandex#search'
}),
objectManager = new ymaps.ObjectManager({
// Чтобы метки начали кластеризоваться, выставляем опцию.
clusterize: true,
// ObjectManager принимает те же опции, что и кластеризатор.
gridSize: 32
});
// Чтобы задать опции одиночным объектам и кластерам,
// обратимся к дочерним коллекциям ObjectManager.
objectManager.objects.options.set('preset', 'islands#greenDotIcon');
objectManager.clusters.options.set('preset', 'islands#greenClusterIcons');
myMap.geoObjects.add(objectManager);
// Добавим метки
var data = {
"type": "FeatureCollection",
"features": [
{"type": "Feature", "id": 0, "geometry": {"type": "Point", "coordinates": [55.831903, 37.411961]}, "properties": {"balloonContent": "Содержимое балуна", "clusterCaption": "Еще одна метка", "hintContent": "Текст подсказки"}},
{"type": "Feature", "id": 1, "geometry": {"type": "Point", "coordinates": [55.763338, 37.565466]}, "properties": {"balloonContent": "Содержимое балуна", "clusterCaption": "Еще одна метка", "hintContent": "Текст подсказки"}},
{"type": "Feature", "id": 2, "geometry": {"type": "Point", "coordinates": [55.723318, 37.525426]}, "properties": {"balloonContent": "Содержимое балуна", "clusterCaption": "Еще одна метка", "hintContent": "Текст подсказки"}},
{"type": "Feature", "id": 3, "geometry": {"type": "Point", "coordinates": [55.723318, 37.525426]}, "properties": {"balloonContent": "Содержимое балуна", "clusterCaption": "Еще одна метка", "hintContent": "Текст подсказки"}},
]
}
objectManager.add(data);
}
</script>
<div id="map"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment