summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2017-02-17 12:09:30 +0100
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-02-20 16:52:18 -0800
commita0992f05504ae093b5f770a5e5324307a12fc002 (patch)
treebd883e0b8c48ec592390f063b6195e162af5d064
parent55804f827316804a84eb10df1235f0a05501f1c3 (diff)
downloadqtlocation-mapboxgl-a0992f05504ae093b5f770a5e5324307a12fc002.tar.gz
[core] - allow moveBy to use AnimationOptions
[android] - update jni bindings for moveBy with an interpolator
-rw-r--r--include/mbgl/map/map.hpp3
-rwxr-xr-xplatform/android/src/jni.cpp9
-rw-r--r--src/mbgl/map/map.cpp4
-rw-r--r--src/mbgl/map/transform.cpp4
-rw-r--r--src/mbgl/map/transform.hpp2
5 files changed, 15 insertions, 7 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index c51d7e9ffd..3939ab1881 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -9,6 +9,7 @@
#include <mbgl/util/size.hpp>
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/style/transition_options.hpp>
+#include <mbgl/map/camera.hpp>
#include <cstdint>
#include <string>
@@ -86,7 +87,7 @@ public:
void flyTo(const CameraOptions&, const AnimationOptions&);
// Position
- void moveBy(const ScreenCoordinate&, const Duration& = Duration::zero());
+ void moveBy(const ScreenCoordinate&, const AnimationOptions& = {});
void setLatLng(const LatLng&, optional<ScreenCoordinate>, const Duration& = Duration::zero());
void setLatLng(const LatLng&, optional<EdgeInsets>, const Duration& = Duration::zero());
void setLatLng(const LatLng&, const Duration& = Duration::zero());
diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp
index a0ec21eb9f..3f5f48561b 100755
--- a/platform/android/src/jni.cpp
+++ b/platform/android/src/jni.cpp
@@ -488,7 +488,14 @@ void nativeMoveBy(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdoubl
jlong duration) {
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
- nativeMapView->getMap().moveBy({dx, dy}, mbgl::Milliseconds(duration));
+
+ mbgl::AnimationOptions animationOptions;
+ if (duration > 0) {
+ animationOptions.duration.emplace(mbgl::Milliseconds(duration));
+ animationOptions.easing.emplace(mbgl::util::UnitBezier { 0, 0.3, 0.6, 1.0 });
+ }
+
+ nativeMapView->getMap().moveBy({dx, dy}, animationOptions);
}
void nativeSetLatLng(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdouble latitude, jdouble longitude, jlong duration) {
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 82c0a5f901..247cc50b59 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -478,9 +478,9 @@ void Map::flyTo(const CameraOptions& camera, const AnimationOptions& animation)
#pragma mark - Position
-void Map::moveBy(const ScreenCoordinate& point, const Duration& duration) {
+void Map::moveBy(const ScreenCoordinate& point, const AnimationOptions& animation) {
impl->cameraMutated = true;
- impl->transform.moveBy(point, duration);
+ impl->transform.moveBy(point, animation);
impl->onUpdate(Update::Repaint);
}
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index ba5e205301..ba6111c32d 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -322,7 +322,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
#pragma mark - Position
-void Transform::moveBy(const ScreenCoordinate& offset, const Duration& duration) {
+void Transform::moveBy(const ScreenCoordinate& offset, const AnimationOptions& animation) {
ScreenCoordinate centerOffset = {
offset.x,
-offset.y,
@@ -331,7 +331,7 @@ void Transform::moveBy(const ScreenCoordinate& offset, const Duration& duration)
CameraOptions camera;
camera.center = state.screenCoordinateToLatLng(centerPoint);
- easeTo(camera, duration);
+ easeTo(camera, animation);
}
void Transform::setLatLng(const LatLng& latLng, const Duration& duration) {
diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp
index febe71035d..cbe1ad7b95 100644
--- a/src/mbgl/map/transform.hpp
+++ b/src/mbgl/map/transform.hpp
@@ -44,7 +44,7 @@ public:
/** Pans the map by the given amount.
@param offset The distance to pan the map by, measured in pixels from
top to bottom and from left to right. */
- void moveBy(const ScreenCoordinate& offset, const Duration& = Duration::zero());
+ void moveBy(const ScreenCoordinate& offset, const AnimationOptions& = {});
void setLatLng(const LatLng&, const Duration& = Duration::zero());
void setLatLng(const LatLng&, optional<EdgeInsets>, const Duration& = Duration::zero());
void setLatLng(const LatLng&, optional<ScreenCoordinate>, const Duration& = Duration::zero());