diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-01-26 16:59:54 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-01-26 18:49:01 -0800 |
commit | 8a23bdcd0194ec86857ff4dd1201b98dfe49bb48 (patch) | |
tree | 4d54330e88f855d5c5be770f770182b77fd4a3b2 /platform | |
parent | 97fc2120c43ed53d3baa4a55f7fe1bb72e36427d (diff) | |
download | qtlocation-mapboxgl-8a23bdcd0194ec86857ff4dd1201b98dfe49bb48.tar.gz |
[core, ios, osx] Tilt around visual center point
The tilt gesture on both iOS and OS X now respects the content insets. On iOS, in user tracking mode, it additionally respects the user dot’s position if it’s aligned to the top or bottom of the view.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/src/jni.cpp | 5 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 9 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView.mm | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp index cc25ec4da0..cd013e4519 100644 --- a/platform/android/src/jni.cpp +++ b/platform/android/src/jni.cpp @@ -680,11 +680,12 @@ jdouble JNICALL nativeGetPitch(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) return nativeMapView->getMap().getPitch(); } -void JNICALL nativeSetPitch(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble pitch, jlong duration) { +void JNICALL nativeSetPitch(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble pitch, jlong milliseconds) { mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetPitch"); assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr); - nativeMapView->getMap().setPitch(pitch, mbgl::Milliseconds(duration)); + mbgl::Duration duration((mbgl::Milliseconds(milliseconds))); + nativeMapView->getMap().setPitch(pitch, duration); } void JNICALL nativeScaleBy(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jdouble ds, jdouble cx, diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index d499dc7474..1952597a4c 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1428,8 +1428,13 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) CGFloat slowdown = 20.0; CGFloat pitchNew = currentPitch - (gestureDistance / slowdown); - - _mbglMap->setPitch(pitchNew); + + CGPoint centerPoint = self.contentCenter; + if (self.userTrackingMode != MGLUserTrackingModeNone) + { + centerPoint = self.userLocationAnnotationViewCenter; + } + _mbglMap->setPitch(pitchNew, centerPoint); [self notifyMapChange:mbgl::MapChangeRegionIsChanging]; } diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 3bea3f1139..fe95427e52 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -1207,7 +1207,7 @@ public: [self didChangeValueForKey:@"direction"]; } if (self.pitchEnabled) { - _mbglMap->setPitch(_pitchAtBeginningOfGesture + delta.y / 5); + _mbglMap->setPitch(_pitchAtBeginningOfGesture + delta.y / 5, center); } } } else if (self.scrollEnabled) { |