Automatic marker zoom

1

I use this code to retrieve Lat and lang from a user in firebase, My question is how to automatically zoom in on the bookmark ...

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);


               }
    
asked by anonymous 20.02.2017 / 15:36

1 answer

4

Use an object of type CameraUpdate together with the method animateCamera()

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

Set the zoom value to the desired zoom.

    
20.02.2017 / 16:05