How do I center my location when I click on a marker?

1

Hi!

I'm developing an application that works on Google Maps API v2 and I've already set the mMap.setMyLocationEnabed(true) method to get the user's location.

My question is: how do I, by clicking on this blue dot that appears, center the map?

    
asked by anonymous 25.08.2015 / 17:02

1 answer

1

Follows:

LatLng isMe = new LatLng(mMap.getMyLocation().getLatitude(), map.getMyLocation().getLongitude());

    final CameraPosition position = new CameraPosition(isMe, ZOOM_APROXIMADO, map.getCameraPosition().tilt, map.getCameraPosition().bearing);
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(position));

I hope I have helped!

Best wishes,

Correction according to comment:
To keep the pattern the way you did:

LatLng isMe = new LatLng(mGoogleMap.getMyLocation().getLatitude(), mGoogleMap.getMyLocation().getLongitude());  
    CameraPosition cp = new CameraPosition.Builder().target(isMe).zoom(5).build();  
    mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cp)); 

Let's change only the fixed position for your Map Position (the Blue Point).

    
03.09.2015 / 13:27