Search code examples
androidgoogle-maps-mobilegoogle-maps-android-api-2

Android Google Maps v2 - set zoom level for myLocation


Is it possible to change the zoom level for myLocation with the new Google Maps API v2?

If you set GoogleMap.setEnableMyLocation(true);, you get a button on the map to find your location.

If you click on it, then the map will bring you to your location and zoom it in to some level. Can I change this zoom to be less or more?


Solution

  • It's doubtful you can change it on click with the default myLocation Marker. However, if you would like the app to automatically zoom in on your location once it is found, I would check out my answer to this question

    Note that the answer I provided does not zoom in, but if you modify the onLocationChanged method to be like the one below, you can choose whatever zoom level you like:

    @Override
    public void onLocationChanged(Location location) {
        if( mListener != null ) {
            mListener.onLocationChanged( location );
    
            //Move the camera to the user's location and zoom in!
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 12.0f));
        }
    }