From 78a12d9d4756ba032cb63801ebd6443656b477f5 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 14 Mar 2016 11:31:01 +0200 Subject: [PATCH] [core] Ignore shortest path when gesturing in Transform::easeTo If gesture in progress, we transfer the world rounds from the end longitude into start, so we can guarantee the "scroll effect" of rounding the world while assuring the end longitude remains wrapped. Otherwise, find the shortest path. --- src/mbgl/map/transform.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 29fa7c9eb..b28325143 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -77,7 +77,8 @@ void Transform::jumpTo(const CameraOptions& camera) { * not included in `options`. */ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& animation) { - const LatLng latLng = camera.center.value_or(getLatLng()).wrapped(); + const LatLng unwrappedLatLng = camera.center.value_or(getLatLng()); + const LatLng latLng = unwrappedLatLng.wrapped(); double zoom = camera.zoom.value_or(getZoom()); double angle = camera.angle.value_or(getAngle()); double pitch = camera.pitch.value_or(getPitch()); @@ -89,8 +90,13 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim // Determine endpoints. EdgeInsets padding; if (camera.padding) padding = *camera.padding; - LatLng startLatLng = getLatLng(padding).wrapped(); - startLatLng.unwrapForShortestPath(latLng); + LatLng startLatLng = getLatLng(padding); + // If gesture in progress, we transfer the world rounds from the end + // longitude into start, so we can guarantee the "scroll effect" of rounding + // the world while assuring the end longitude remains wrapped. + if (isGestureInProgress()) startLatLng.longitude -= unwrappedLatLng.longitude - latLng.longitude; + // Find the shortest path otherwise. + else startLatLng.unwrapForShortestPath(latLng); const ScreenCoordinate startPoint = { state.lngX(startLatLng.longitude),