Google maps api v2 zooming near the marker

Ravi picture Ravi · May 9, 2013 · Viewed 28.7k times · Source

I am using Google maps api v2 in android. I have placed a marker by using latitude and longitude . The marker is shown at correct place , but i want the the map should show area around the marker only .i.e i want to zoom to markers position when the map is shown so it shows nearby region of the marker only..any help would be great.

Answer

TheFlash picture TheFlash · May 9, 2013

pass your current location in this function where you have placed your marker.

private void moveToCurrentLocation(LatLng currentLocation)
{   
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation,15));
    // Zoom in, animating the camera.
    googleMap.animateCamera(CameraUpdateFactory.zoomIn());
    // Zoom out to zoom level 10, animating with a duration of 2 seconds.
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);


}