Answer the question
In order to leave comments, you need to log in
How to get the id of the visible points of Yandex maps?
how to get the id of the points that fell into the scope when dragging/zooming the map?
var placemark = [];
$.getJSON(document.location.pathname+"results.json", function(data) {
for (var i in data) {
var company = data[i];
placemark[company.id] = new ymaps.Placemark(company['tv.coords'].split(','), {
preset: 'islands#redIcon'
}
);
clusterer.add(placemark[company.id]);
}
});
map.geoObjects.add(clusterer);
Answer the question
In order to leave comments, you need to log in
As far as I know, it's not possible. you need to explicitly iterate over the points and compare the coordinates with the boundaries of the map. although, as for me, the method is very in demand and it is strange that it is not in the api
this.checkVisibleOrCenter = function(placemark) {
var placeMarkCoordinates = placemark.geometry.getCoordinates(),
mapBounds = this.mapObject.getBounds(),
mapBotLeft = mapBounds[0],
mapTopRight = mapBounds[1];
if (
placeMarkCoordinates[0] < mapBotLeft[0]
||
placeMarkCoordinates[0] > mapTopRight[0]
||
placeMarkCoordinates[1] < mapBotLeft[1]
||
placeMarkCoordinates[1] > mapTopRight[1]
) {
// placemark not visible, set map center to it
this.mapObject.setCenter(placeMarkCoordinates);
}
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question