Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #2805 - CameraUpdate and animateCamera() API
Browse files Browse the repository at this point in the history
  • Loading branch information
bleege committed Dec 2, 2015
1 parent d289f23 commit 48f8bbf
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
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;
Expand Down Expand Up @@ -1101,6 +1102,21 @@ public void setScrollEnabled(boolean scrollEnabled) {
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
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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;
Expand Down Expand Up @@ -55,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
.build(); // Creates a CameraPosition from the builder

// Triggers tilt
//mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
mMapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}

@Override
Expand Down

0 comments on commit 48f8bbf

Please sign in to comment.