M
M
morpeh582021-05-13 12:55:17
JavaScript
morpeh58, 2021-05-13 12:55:17

How to filter Placemarks included in the map view area so that when the balloon is opened, it does not close?

First, a Clusterer is created, to which Placemarks will be added.
The handler is hung on the boundschange event

Ymap.events.add('boundschange', this.handleChange);

Next, a selection is made by objects
const query = ymaps.geoQuery(this.geoPlaceMarks);
const visibleGeoObjects = query.searchInside(mapInstance);

Further filtering what to add, what to remove from the cluster
const geoObjectsToRemove = this.geoPlaceMarks.filter(({ properties }) => ids.some(id => id !== properties.get('id')));
const geoObjectsToAdd = this.geoPlaceMarks.filter(({ properties }) => ids.some(id => id === properties.get('id')));
clusterInstance.remove(geoObjectsToRemove);
clusterInstance.add(geoObjectsToAdd);

Does anyone know a better way?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question