THIS IS NOT A DUPLICATE OF Android map v2 zoom to show all the markers
i tried the answer posted in the above link and it did not work for me and that is why i asked the question
i am displaying two markers on google maps. the first time the map is loaded and the map is set, the zoom is set correctly. but when the marker position changes, the zoom level is not changing.
here is my code. i want the zoom level to change when the marker location is changed and i want to scale the map in a way to include BOTH markers
SubscriberMarker = map.addMarker(new MarkerOptions().position(new LatLng(SUBSCRIBER_LAT, SUBSCRIBER_LNG)).title("Home Location").icon(BitmapDescriptorFactory.fromResource(R.drawable.home)));
builder.include(SubscriberMarker.getPosition());
_MyBound = builder.build();
// this part is called when the location is changed:
if (FTMarker!=null)
{
FTMarker.remove();
}
FTMarker = googleMap.addMarker(new MarkerOptions().position(new LatLng(LAT,LNG)).title("FT Location").icon(BitmapDescriptorFactory.fromResource(R.drawable.woker)));
builder.include(FTMarker.getPosition());
_MyBound = builder.build();
// the zoom function is called after that
public void zoom()
{
if (mapView!=null) {
int padding_percent = 20;
int padding = Math.min(mapView.getHeight(), mapView.getWidth()) * padding_percent / 100;
googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(_MyBound, mapView.getWidth(), mapView.getHeight(), padding));
}
}