found somewhere on the mapsforge issue.
public static boolean zoomAndPan(MapView mapView, int minLatE6, int
maxLatE6, int minLngE6, int maxLngE6)
{
int width = mapView.getWidth();
int heigth = mapView.getHeight();
if (width <= 0 || heigth <= 0) {
return false;
}
int cntLat = (maxLatE6 + minLatE6) / 2;
int cntLng = (maxLngE6 + minLngE6) / 2;
mapView.getController().setCenter(new GeoPoint(cntLat,
cntLng));
GeoPoint pointSouthWest = new GeoPoint(minLatE6, minLngE6);
GeoPoint pointNorthEast = new GeoPoint(maxLatE6, maxLngE6);
Projection projection = mapView.getProjection();
Point pointSW = new Point();
Point pointNE = new Point();
byte maxLvl = (byte)
mapView.getMapGenerator().getZoomLevelMax();
byte zoomLevel = 0;
for (; zoomLevel < maxLvl;) {
byte tmpZoomLevel = (byte) (zoomLevel + 1);
projection.toPoint(pointSouthWest, pointSW, tmpZoomLevel);
projection.toPoint(pointNorthEast, pointNE, tmpZoomLevel);
if (pointNE.x - pointSW.x > width) {
break;
}
if (pointSW.y - pointNE.y > heigth) {
break;
}
zoomLevel = tmpZoomLevel;
}
mapView.getController().setZoom(zoomLevel);
return true;
> signature.asc
> < 1KViewDownload