[android] #2805 - Updating Tilt API to support animation duration time
This commit is contained in:
@@ -1123,12 +1123,17 @@ public final class MapView extends FrameLayout {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Tilt in degrees of the MapView
|
||||
* Sets the Tilt in degrees of the MapView.
|
||||
* @param pitch New tilt in degrees
|
||||
* @param duration Animation time in milliseconds. If null then 0 is used, making the animation immediate.
|
||||
*/
|
||||
@FloatRange(from = 0.0, to = 60.0)
|
||||
public void setTilt(double pitch) {
|
||||
mNativeMapView.setPitch(pitch);
|
||||
public void setTilt(Double pitch, @Nullable Long duration) {
|
||||
long actualDuration = 0;
|
||||
if (duration != null) {
|
||||
actualDuration = duration;
|
||||
}
|
||||
mNativeMapView.setPitch(pitch, actualDuration);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1148,7 +1153,7 @@ public final class MapView extends FrameLayout {
|
||||
|
||||
setBearing(update.getBearing());
|
||||
|
||||
setTilt(update.getTilt());
|
||||
setTilt((double)update.getTilt(), null);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -260,8 +260,8 @@ final class NativeMapView {
|
||||
return nativeGetPitch(mNativeMapViewPtr);
|
||||
}
|
||||
|
||||
public void setPitch(double pitch) {
|
||||
nativeSetPitch(mNativeMapViewPtr, pitch);
|
||||
public void setPitch(double pitch, long duration) {
|
||||
nativeSetPitch(mNativeMapViewPtr, pitch, duration);
|
||||
}
|
||||
|
||||
public void scaleBy(double ds) {
|
||||
@@ -543,7 +543,7 @@ final class NativeMapView {
|
||||
|
||||
private native double nativeGetPitch(long nativeMapViewPtr);
|
||||
|
||||
private native void nativeSetPitch(long nativeMapViewPtr, double pitch);
|
||||
private native void nativeSetPitch(long nativeMapViewPtr, double pitch, long duration);
|
||||
|
||||
private native void nativeScaleBy(long nativeMapViewPtr, double ds,
|
||||
double cx, double cy, long duration);
|
||||
|
||||
@@ -45,7 +45,8 @@ public class TiltActivity extends AppCompatActivity {
|
||||
mMapView.onCreate(savedInstanceState);
|
||||
|
||||
Log.i(TiltActivity.class.getCanonicalName(), "Original Tilt = " + mMapView.getTilt());
|
||||
mMapView.setTilt(45);
|
||||
// Tilt Map 45 degrees over 10 seconds
|
||||
mMapView.setTilt(45.0, 10000l);
|
||||
Log.i(TiltActivity.class.getCanonicalName(), "Changed Tilt = " + mMapView.getTilt());
|
||||
|
||||
/*
|
||||
|
||||
@@ -671,11 +671,11 @@ jdouble JNICALL nativeGetPitch(JNIEnv *env, jobject obj, jlong nativeMapViewPtr)
|
||||
return nativeMapView->getMap().getPitch();
|
||||
}
|
||||
|
||||
void JNICALL nativeSetPitch(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble pitch) {
|
||||
void JNICALL nativeSetPitch(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble pitch, jlong duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetPitch");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
nativeMapView->getMap().setPitch(pitch, std::chrono::milliseconds(0));
|
||||
nativeMapView->getMap().setPitch(pitch, std::chrono::milliseconds(duration));
|
||||
}
|
||||
|
||||
void JNICALL nativeScaleBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble ds, jdouble cx,
|
||||
@@ -1903,7 +1903,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
reinterpret_cast<void *>(&nativeGetLatLng)},
|
||||
{"nativeResetPosition", "(J)V", reinterpret_cast<void *>(&nativeResetPosition)},
|
||||
{"nativeGetPitch", "(J)D", reinterpret_cast<void *>(&nativeGetPitch)},
|
||||
{"nativeSetPitch", "(JD)V", reinterpret_cast<void *>(&nativeSetPitch)},
|
||||
{"nativeSetPitch", "(JDJ)V", reinterpret_cast<void *>(&nativeSetPitch)},
|
||||
{"nativeScaleBy", "(JDDDJ)V", reinterpret_cast<void *>(&nativeScaleBy)},
|
||||
{"nativeSetScale", "(JDDDJ)V", reinterpret_cast<void *>(&nativeSetScale)},
|
||||
{"nativeGetScale", "(J)D", reinterpret_cast<void *>(&nativeGetScale)},
|
||||
|
||||
Reference in New Issue
Block a user