Answer the question
In order to leave comments, you need to log in
How to add a balloon when adding objects to the map that fall into the scope?
Is there any code that adds objects to the map that fall into the scope?
var objects = ymaps.geoQuery(coords.map(function(p){return {coordinates:p, type: 'Point'}}));
objects.searchInside(myMap).addToMap(myMap);
myMap.events.add('boundschange', function () {
var visibleObjects = objects.searchInside(myMap).addToMap(myMap);
objects.remove(visibleObjects).removeFromMap(myMap);
});
var placemark = new YMaps.Placemark(new YMaps.GeoPoint(37.64, 55.76));
placemark.name = "Имя метки";
placemark.description = "Описание метки";
map.addOverlay(placemark);
Answer the question
In order to leave comments, you need to log in
I decided, I throw the working code
var obj = {
type: 'FeatureCollection',
features: coords.map(function(p){
return {
type: 'Feature',
properties: {
balloonContent: p[2]
},
geometry: {
type: 'Point',
coordinates: [p[0], p[1]]
}
}
})
};
var objects = ymaps.geoQuery(obj);
objects.searchInside(myMap).addToMap(myMap);
myMap.events.add('boundschange', function () {
var visibleObjects = objects.searchInside(myMap).addToMap(myMap);
objects.remove(visibleObjects).removeFromMap(myMap);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question