N
N
nastya_zholudeva2017-10-17 11:44:32
API
nastya_zholudeva, 2017-10-17 11:44:32

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);
                            });

I can't put a balloon on every label. I try even the simplest code from the documentation,
var placemark = new YMaps.Placemark(new YMaps.GeoPoint(37.64, 55.76));
placemark.name = "Имя метки";
placemark.description = "Описание метки";
map.addOverlay(placemark);

but it doesn't work :(((

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nastya_zholudeva, 2017-10-17
@nastya_zholudeva

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 question

Ask a Question

731 491 924 answers to any question