Zooming Animation in Google Maps

Viewed 6555

I am learning about Google Maps API on Android and I have just learned how to do this.

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
    // Add a marker in Uman and move the camera
    LatLng uman = new LatLng(48.754683, 30.216339 );
    mMap.addMarker(new MarkerOptions().position(uman).title("Home Town"));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(uman, 10));
}

But instead of the map loading directly into the marker, I want it to load fully zoomed out, and zoom in into the marker in an animation...

Really hope that makes sense...

3 Answers

for animation replace moveCamera to animateCamera

java

map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));

kotlin:

 val cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 15f)
 map.animateCamera(cameraUpdate)
Related