Thursday, 2 January 2014

Android Google Map

Cover All markers in Map



LatLngBounds bounds = builder.build();

To do this, first calculate the bounds of all the markers like so:

LatLngBounds.Builder builder = new LatLngBounds.Builder();

for (Marker marker : markers) {
    builder.include(marker.getPosition());
}
LatLngBounds bounds = builder.build();

Finally move the map:

googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(
bounds, width, height, 150));

No comments:

Post a Comment