I have a cluster marker that defines a bounding rectangle containing a group of markers. The cluster has a center (lat,lon), a marker count and a latitude and longitude span to
Thank you for your answer Solvek. Meanwhile I found a solution that I've adapted slightly and it works. The method computes the bounds of a set of geo points, computes the span of these points and finally uses zoomToSpan and animateTo for zooming into and centering the given area:
public static void zoomInBounds(final MapView view, final GeoPoint.. bounds) {
int minLat = Integer.MAX_VALUE;
int minLong = Integer.MAX_VALUE;
int maxLat = Integer.MIN_VALUE;
int maxLong = Integer.MIN_VALUE;
for (GeoPoint point : bounds) {
minLat = Math.min(point.getLatitudeE6(), minLat);
minLong = Math.min(point.getLongitudeE6(), minLong);
maxLat = Math.max(point.getLatitudeE6(), maxLat);
maxLong = Math.max(point.getLongitudeE6(), maxLong);
}
final MapController controller = view.getController();
controller.zoomToSpan(
Math.abs(minLat - maxLat), Math.abs(minLong - maxLong));
controller.animateTo(new GeoPoint((maxLat + minLat) / 2,
(maxLong + minLong) / 2));
}