Reputation: 1598
I'm trying to find if there's an algorithm/method out there that can help determine a suitable zoom level for initial display.
For example, given a set of locations Point A,B,C,D and E, how can I determine the correct zoom level that will display all locations on the screen?
Upvotes: 1
Views: 1760
Reputation: 1547
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);
Upvotes: 3