I am plotting a route using the osmdroid bonuspack. The start and end coordinates of this route are:-
origin - 52.24896,0.71795
destination - 54.27916,-1.9732
The relevant part of my code is:-
BoundingBox b = getBoundingBox(origin,destination);
map.setMinZoomLevel(7d); // <<==== Needed to initialise zoom level
map.zoomToBoundingBox(b,false);
map.invalidate();
and
private BoundingBox getBoundingBox(GeoPoint start, GeoPoint end) {
double north;
double south;
double east;
double west;
if(start.getLatitude() > end.getLatitude()) {
north = start.getLatitude();
south = end.getLatitude();
} else {
north = end.getLatitude();
south = start.getLatitude();
}
if(start.getLongitude() > end.getLongitude()) {
east = start.getLongitude();
west = end.getLongitude();
} else {
east = end.getLongitude();
west = start.getLongitude();
}
return new BoundingBox(north, east, south, west);
}
The map tiles I'm using are zoom levels 7-13.
Without the 'setMinZoomLevel' statement the origin/destination markers are displayed in the top left corner of the screen at a zoom level that can best be described as deep space. If I include 'setMinZoomLevel' then the map is displayed at that level and doesn't zoom to fit the boundingbox (which should be at level 8). I have tried a much smaller route with exactly the same end result.
What am I doing wrong?