Automatic zoom on marker

Asked

Viewed 124 times

1

I use this code to retrieve Lat and lang from a user in firebase, My doubt is how to give an automatic (animated) zoom in the marker...

mDatabase.child(mPost_key).addValueEventListener(new ValueEventListener() {
               @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Location childLocation = dataSnapshot.getValue(Location.class);
            LatLng childPos = new LatLng(childLocation.getLat(),childLocation.getLang());
            MarkerOptions markerOptions  =new MarkerOptions().position(childPos);
            Marker marker = mMap.addMarker(markerOptions);
            userMarkers.put(dataSnapshot.getKey(),marker);


               }

1 answer

4


Use a Cameraupdate object along with the method animateCamera()

CameraUpdate update = CameraUpdateFactory.newLatLngZoom(childPos, zoom);
mMap.animateCamera(update);

Set the value of zoom according to the desired zoom.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.