0

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)

enter image description here

Screen 2 : Expected output screen. I need all the marker should visible in the map visible region.

enter image description here

M.A.Murali
  • 9,988
  • 36
  • 105
  • 182
  • Seems to be the same as: http://stackoverflow.com/questions/14828217/android-map-v2-zoom-to-show-all-the-markers?rq=1 Maybe try without specifying width/height? – Andy Mar 04 '15 at 17:00
  • check this http://stackoverflow.com/questions/28813371/move-camera-position-to-fit-latlngbounds-with-regard-to-marker-height – Marian Paździoch Mar 13 '15 at 08:33

0 Answers0