summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-03-14 11:31:01 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-03-14 11:51:37 +0200
commit78a12d9d4756ba032cb63801ebd6443656b477f5 (patch)
tree38ee00167e9168807d0d5e60fc69278a16ed58e9 /src
parentb5bb48edaa0a553a4b91c3632148bf86ac9e2bf6 (diff)
downloadqtlocation-mapboxgl-78a12d9d4756ba032cb63801ebd6443656b477f5.tar.gz
[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.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/transform.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 29fa7c9eb2..b283251431 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),