[android] #2805 - CameraUpdate and animateCamera() API
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.mapbox.mapboxsdk.camera;
|
||||
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
public final class CameraUpdate {
|
||||
|
||||
/**
|
||||
* Direction that the camera is pointing in, in degrees clockwise from north.
|
||||
*/
|
||||
private final float bearing;
|
||||
|
||||
/**
|
||||
* The location that the camera is pointing at.
|
||||
*/
|
||||
private final LatLng target;
|
||||
|
||||
/**
|
||||
* The angle, in degrees, of the camera angle from the nadir (directly facing the Earth). See tilt(float) for details of restrictions on the range of values.
|
||||
*/
|
||||
private final float tilt;
|
||||
|
||||
/**
|
||||
* Zoom level near the center of the screen. See zoom(float) for the definition of the camera's zoom level.
|
||||
*/
|
||||
private final float zoom;
|
||||
|
||||
/**
|
||||
* Package Private Constructor to only be used CameraUpdateFactory
|
||||
* @param bearing Final Bearing
|
||||
* @param target Final Target
|
||||
* @param tilt Final Tilt
|
||||
* @param zoom Final Zoom
|
||||
*/
|
||||
CameraUpdate(float bearing, LatLng target, float tilt, float zoom) {
|
||||
this.bearing = bearing;
|
||||
this.target = target;
|
||||
this.tilt = tilt;
|
||||
this.zoom = zoom;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mapbox.mapboxsdk.camera;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
public class CameraUpdateFactory {
|
||||
|
||||
/**
|
||||
* Returns a CameraUpdate that moves the camera to a specified CameraPosition.
|
||||
* @param cameraPosition Camera Position to change to
|
||||
* @return CameraUpdate Final Camera Position data
|
||||
*/
|
||||
public static CameraUpdate newCameraPosition (@NonNull CameraPosition cameraPosition) {
|
||||
return new CameraUpdate(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom);
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,7 @@ import com.mapbox.mapboxsdk.annotations.Polyline;
|
||||
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Sprite;
|
||||
import com.mapbox.mapboxsdk.annotations.SpriteFactory;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdate;
|
||||
import com.mapbox.mapboxsdk.constants.MyBearingTracking;
|
||||
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
@@ -1101,6 +1102,21 @@ public final class MapView extends FrameLayout {
|
||||
this.mScrollEnabled = scrollEnabled;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Mirrored Google Map's Camera API
|
||||
//
|
||||
|
||||
/**
|
||||
* Animates the movement of the camera from the current position to the position defined in the update.
|
||||
* See CameraUpdateFactory for a set of updates.
|
||||
* @param update The change that should be applied to the camera.
|
||||
*/
|
||||
@UiThread
|
||||
public final void animateCamera (CameraUpdate update) {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Rotation
|
||||
//
|
||||
|
||||
@@ -5,8 +5,8 @@ import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.utils.ApiAccess;
|
||||
@@ -55,7 +55,7 @@ public class TiltActivity extends AppCompatActivity {
|
||||
.build(); // Creates a CameraPosition from the builder
|
||||
|
||||
// Triggers tilt
|
||||
//mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user