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

Commit

Permalink
[android] #4326 - using the camera API vs getCameraPosition should re…
Browse files Browse the repository at this point in the history
…turn same output
  • Loading branch information
tobrun authored and bleege committed Mar 21, 2016
1 parent 8dd6c06 commit d329800
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,15 @@ public final void moveCamera(CameraUpdate update) {
*/
@UiThread
public final void moveCamera(CameraUpdate update, MapboxMap.CancelableCallback callback) {
mCameraPosition = update.getCameraPosition(this);
mMapView.jumpTo(mCameraPosition.bearing, mCameraPosition.target, mCameraPosition.tilt, mCameraPosition.zoom);
CameraPosition position = update.getCameraPosition(this);
mMapView.jumpTo(position.bearing, position.target, position.tilt, position.zoom);
if (mOnCameraChangeListener != null) {
mOnCameraChangeListener.onCameraChange(mCameraPosition);
}
if (callback != null) {
callback.onFinish();
}
invalidateCameraPosition();
}

/**
Expand Down Expand Up @@ -288,24 +289,22 @@ public final void easeCamera(CameraUpdate update, int durationMs) {
*/
@UiThread
public final void easeCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) {
mCameraPosition = update.getCameraPosition(this);
mMapView.easeTo(mCameraPosition.bearing, mCameraPosition.target, getDurationNano(durationMs), mCameraPosition.tilt, mCameraPosition.zoom, new CancelableCallback() {
CameraPosition position = update.getCameraPosition(this);
mMapView.easeTo(position.bearing, position.target, getDurationNano(durationMs), position.tilt, position.zoom, new CancelableCallback() {
@Override
public void onCancel() {
if (callback != null) {
callback.onCancel();
}
invalidateCameraPosition();
}

@Override
public void onFinish() {
if (mOnCameraChangeListener != null) {
mOnCameraChangeListener.onCameraChange(mCameraPosition);
}

if (callback != null) {
callback.onFinish();
}
invalidateCameraPosition();
}
});
}
Expand Down Expand Up @@ -358,13 +357,14 @@ public final void animateCamera(CameraUpdate update, int durationMs) {
*/
@UiThread
public final void animateCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) {
mCameraPosition = update.getCameraPosition(this);
mMapView.flyTo(mCameraPosition.bearing, mCameraPosition.target, getDurationNano(durationMs), mCameraPosition.tilt, mCameraPosition.zoom, new CancelableCallback() {
CameraPosition cameraPosition = update.getCameraPosition(this);
mMapView.flyTo(cameraPosition.bearing, cameraPosition.target, getDurationNano(durationMs), cameraPosition.tilt, cameraPosition.zoom, new CancelableCallback() {
@Override
public void onCancel() {
if (callback != null) {
callback.onCancel();
}
invalidateCameraPosition();
}

@Override
Expand All @@ -376,6 +376,7 @@ public void onFinish() {
if (callback != null) {
callback.onFinish();
}
invalidateCameraPosition();
}
});
}
Expand Down

0 comments on commit d329800

Please sign in to comment.