From 97c143a3388647e74a9f74a4994ab9d6aafe26a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Fri, 18 Dec 2015 22:02:50 -0800 Subject: [core] Fly across the meridian or antemeridian, whichever is shorter ref mapbox/mapbox-gl-js#1853 --- src/mbgl/map/transform.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 759e6b4e0f..badd5d89a3 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -344,6 +344,16 @@ void Transform::flyTo(const CameraOptions &options) { return; } + // If a path crossing the antemeridian would be shorter, extend the final + // coordinate so that interpolating between the two endpoints will cross it. + if (std::abs(startLatLng.longitude) + std::abs(latLng.longitude) > 180) { + if (startLatLng.longitude > 0 && latLng.longitude < 0) { + latLng.longitude += 360; + } else if (startLatLng.longitude < 0 && latLng.longitude > 0) { + latLng.longitude -= 360; + } + } + const PrecisionPoint startPoint = { state.lngX(startLatLng.longitude), state.latY(startLatLng.latitude), -- cgit v1.2.1