📅  最后修改于: 2022-03-11 14:52:39.690000             🧑  作者: Mango
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
//When Map Loads Successfully
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
LatLng customMarkerLocationOne = new LatLng(28.583911, 77.319116);
LatLng customMarkerLocationTwo = new LatLng(28.583078, 77.313744);
LatLng customMarkerLocationThree = new LatLng(28.580903, 77.317408);
LatLng customMarkerLocationFour = new LatLng(28.580108, 77.315271);
//LatLngBound will cover all your marker on Google Maps
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(customMarkerLocationOne); //Taking Point A (First LatLng)
builder.include(customMarkerLocationThree); //Taking Point B (Second LatLng)
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 200);
mMap.moveCamera(cu);
mMap.animateCamera(CameraUpdateFactory.zoomTo(14), 2000, null);
}
});
}