In my Android application, I have to show all markers in visible region. I am using following code but some of the marker does not visible in the region.
How to show all the markers within the visible region?
Code:
private LatLngBounds.Builder markerBuilder;
......
markerBuilder = new LatLngBounds.Builder();
for (Marker marker : allMarkersArray) {
markerBuilder.include(marker.getPosition());
}
LatLngBounds bounds = markerBuilder.build();
int width = getResources().getDisplayMetrics().widthPixels;
int height = getResources().getDisplayMetrics().heightPixels;
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds,width, height, 10);
googleMap.animateCamera(cu);
The above code produces following output: Screen 1: (Here some of the markers are not visible)
Screen 2 : Expected output screen. I need all the marker should visible in the map visible region.