Вопрос снимается, решение:
supercluster +
geo-viewport + lat/lngDelta region:
export function region(points) {
if(isNaN(points[0].latitude) ) return null;
var minX, maxX, minY, maxY;
// init first point
((point) => {
minX = point.latitude;
maxX = point.latitude;
minY = point.longitude;
maxY = point.longitude;
})(points[0]);
// calculate rect
points.map((point) => {
minX = Math.min(minX, point.latitude);
maxX = Math.max(maxX, point.latitude);
minY = Math.min(minY, point.longitude);
maxY = Math.max(maxY, point.longitude);
});
console.log(points, minX,maxX, (minX + maxX) / 2)
var midX = (minX + maxX) / 2;
var midY = (minY + maxY) / 2;
var midPoint = [midX, midY];
var deltaX = (maxX - minX);
var deltaY = (maxY - minY);
return {
latitude: midX, longitude: midY,
latitudeDelta: deltaX, longitudeDelta: deltaY,
};
}