android – Google maps api v2 zooming near the marker-ThrowExceptions

Exception or error:

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.

How to solve:

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

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



Provide marker position.

private void pointToPosition(LatLng position) {
    //Build camera position
    CameraPosition cameraPosition = new CameraPosition.Builder()
    //Zoom in and animate the camera.

Leave a Reply

Your email address will not be published. Required fields are marked *