This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Determining suitable zoom level based on a set of locations for OSMDroid

1

From Google Maps Android API v2, I understand that this can be done through this method:

LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Location loc : allLocations) {
    LatLng position = new LatLng(loc.getLatitude(), loc.getLongitude());
    builder.include(position);
}

CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(builder.build(), someMarginValue);
map.moveCamera(cu);

However I can't seem to find a way to do this for OSMDroid. Is there a solution/ class to help determine the zoom level based on a set of locations?

I need the zoom level to be determined first as I am downloading a specific set of maptiles for offline display. However to do that I need to determine the right zoom level to download from the server first... Are there any algorithms out there that can determine this zoom level first?

asked 07 Feb '13, 11:00

lyk's gravatar image

lyk
41446
accept rate: 0%


One Answer:

0

Maybe the OSM wiki can help about Zoomlevels

answered 07 Feb '13, 22:39

stephan75's gravatar image

stephan75
12.6k556210
accept rate: 6%

Source code available on GitHub .