W
W
wanderbit2015-11-12 09:59:51
Yandex
wanderbit, 2015-11-12 09:59:51

Why doesn't the balloon open when clicking on the menu link and why aren't the properties of the geocollection set?

js code

ymaps.ready(function () {
var myMap = new ymaps.Map('map', {
center: [55.751574, 37.573856],
zoom: 9,
controls: []
}, {
searchControlProvider: 'yandex#search'
});
var searchControl = new ymaps.control.SearchControl({
options: {
position: { left: 250, top: 50 },
// float: 'right',
floatIndex: 100,
noPlacemark: true,
left:50
}
});
var myCollection = new ymaps.GeoObjectCollection();
myCollection.options.set({
iconImageHref: 'https://yastatic.net/morda-logo/i/arrow2/logo_simp... ',
iconImageSize: [95, 37], // image size
iconImageOffset: [-11, -30] // image offset
});
// Adding labels to the collection.
myCollection.add(new ymaps.Placemark([55.743517277269156,37.505507499999915], { id: 'n1', balloonContent: 'Bagrationovskaya Office'}));
myCollection.add(new ymaps.Placemark([55.64192027765163,37.52345549999994], { id: 'n2', balloonContent: 'Bagrationovskaya Office'}));
myCollection.add(new ymaps.Placemark([55.68452827749535,37.62410349999998], { id: 'n3', balloonContent: 'Bagrationovskaya Office'}));
myCollection.add(new ymaps.Placemark([55.42569577845532,37.545419499999944], { id: 'n4', balloonContent: 'Bagrationovskaya office'}));
myCollection.add(new ymaps.Placemark([55.654568777603394,37.540532499999934], { id: 'n5', balloonContent: 'Bagrationovskaya Office'}));
myMap.controls.add(searchControl);
myMap.geoObjects.add(myCollection);
myMap.setBounds(myCollection.getBounds());
// Look for the desired label and open/close its balloon.
function itemToggle(id) {
var it = visible.getIterator(),
group;
while(group = it.getNext()) {
for(var i = 0, len = group.getLength(); i < len; i++) {
var placemark = group.get(i);
if(placemark.properties.get('id') === id) {
if(placemark.balloon.isOpen()) {
placemark.balloon.close();
}
else {
myMap.panTo(placemark.geometry.getCoordinates(), {
delay: 0,
callback: function () {
placemark.balloon.open();
}
});
}
return;
}
}
}
}
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wanderbit, 2015-11-12
@wanderbit Автор вопроса

сама карта wander1.esy.es/yandexmap

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question