Skip to content

Instantly share code, notes, and snippets.

@tolmachevroman
Last active August 29, 2015 14:14
Show Gist options
  • Save tolmachevroman/3426c66d96fb4c44d302 to your computer and use it in GitHub Desktop.
Save tolmachevroman/3426c66d96fb4c44d302 to your computer and use it in GitHub Desktop.
Fit all the markers on the map
LatLngBounds.Builder builder = new LatLngBounds.Builder();
//mMarkers is a List<Marker> with your markers
for (Marker marker : mMarkers) {
builder.include(marker.getPosition());
}
LatLngBounds bounds = builder.build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, PADDING); //padding between screen borders and extreme right/left markers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment