@@ -0,0 +1,3146 @@
+package com.evgenii.walktocircle.WalkMap;%0A%0Aimport android.location.Location;%0A%0Aimport com.evgenii.walktocircle.Utils.WalkLocation;%0Aimport com.evgenii.walktocircle.WalkConstants;%0Aimport com.google.android.gms.maps.CameraUpdate;%0Aimport com.google.android.gms.maps.CameraUpdateFactory;%0Aimport com.google.android.gms.maps.GoogleMap;%0Aimport com.google.android.gms.maps.model.CameraPosition;%0Aimport com.google.android.gms.maps.model.LatLng;%0A%0Apublic class PrepareMapForPin %7B%0A    public void prepare(Location userLocation, Location pinLocation, GoogleMap map, GoogleMap.CancelableCallback callback) %7B%0A        animateCameraToUserLocation(userLocation, map, callback);%0A    %7D%0A%0A    /**%0A     * Animates the camera to current user's location with default zoom level.%0A     * If user's locatino is already shown on the map with proper zoom the camera animation%0A     * is not performed and the callback is called right away.%0A     * @param userLocation location which is used to animate the camera to%0A     * @param map the map object%0A     * @param callback called after camera animation is complete%0A     */%0A    public void animateCameraToUserLocation(Location userLocation, GoogleMap map, GoogleMap.CancelableCallback callback) %7B%0A        CameraUpdate update = getUserCenteredCameraUpdate(userLocation, map);%0A%0A        if (update != null) %7B%0A            map.animateCamera(update, WalkConstants.mapPositionAnimationDurationMilliseconds, callback);%0A        %7D else %7B%0A            callback.onFinish();%0A        %7D%0A    %7D%0A%0A    /**%0A     *%0A     * @return Returns the update for the camera centered at the user at the right zoom level.%0A     * Returns null if no camera update is necessary.%0A     */%0A    private CameraUpdate getUserCenteredCameraUpdate(Location userLocation, GoogleMap map) %7B%0A        LatLng userLatLng = WalkLocation.latLngFromLocation(userLocation);%0A%0A        CameraPosition.Builder cameraPositionBuilder = new CameraPosition.Builder(map.getCameraPosition());%0A        boolean didChangeCamera = false;%0A%0A        Location mapCenter =  WalkLocation.getMapCenter(map);%0A        if (mapCenter.distanceTo(userLocation) %3E WalkConstants.mapMaxDistanceFromMapCenterMeters) %7B%0A            cameraPositionBuilder.target(userLatLng);%0A            didChangeCamera = true;%0A        %7D%0A%0A        float currentZoom = map.getCameraPosition().zoom;%0A        if (Math.abs(WalkConstants.mapInitialZoom - currentZoom) %3E WalkConstants.mapZoomLevelDelta) %7B%0A            cameraPositionBuilder.zoom(WalkConstants.mapInitialZoom);%0A            didChangeCamera = true;%0A        %7D%0A%0A        if (map.getCameraPosition().bearing %3E WalkConstants.mapMaxBearing%0A                && map.getCameraPosition().bearing %3C (360 - WalkConstants.mapMaxBearing)) %7B%0A            cameraPositionBuilder.bearing(0);%0A            didChangeCamera = true;%0A        %7D%0A%0A        if (map.getCameraPosition().tilt %3E WalkConstants.mapMaxTilt) %7B%0A            cameraPositionBuilder.tilt(0);%0A            didChangeCamera = true;%0A        %7D%0A%0A        if (!didChangeCamera) %7B return null; %7D%0A%0A        CameraPosition newCameraPosition = cameraPositionBuilder.build();%0A        return CameraUpdateFactory.newCameraPosition(newCameraPosition);%0A    %7D%0A%7D%0A

Drop pin