Code example for GoogleMap

Methods: animateCamera, setMyLocationEnabled

0
            } 
        } 
    } 
 
    private void setUpMap() { 
        map.setMyLocationEnabled(true);
        map.animateCamera(zoomToLastKnownLatLng());
    } 
 
    private CameraUpdate zoomToLastKnownLatLng() {
        return CameraUpdateFactory.newLatLngZoom(getLastKnownLatLng(), ZOOM_LEVEL);
    } 
 
    private LatLng getLastKnownLatLng() {
        Location location = ((LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE)).getLastKnownLocation("gps");
        return locationToLatLng(location);
    } 
 
    private LatLng locationToLatLng(Location location) {
        return new LatLng(location.getLatitude(), location.getLongitude());
    }