Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 225a17d

Browse files
committed
[core] Fly across the meridian or antemeridian, whichever is shorter
ref mapbox/mapbox-gl-js#1853
1 parent a68589b commit 225a17d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/mbgl/map/transform.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,16 @@ void Transform::flyTo(const CameraOptions &options) {
344344
return;
345345
}
346346

347+
// If a path crossing the antemeridian would be shorter, extend the final
348+
// coordinate so that interpolating between the two endpoints will cross it.
349+
if (std::abs(startLatLng.longitude) + std::abs(latLng.longitude) > 180) {
350+
if (startLatLng.longitude > 0 && latLng.longitude < 0) {
351+
latLng.longitude += 360;
352+
} else if (startLatLng.longitude < 0 && latLng.longitude > 0) {
353+
latLng.longitude -= 360;
354+
}
355+
}
356+
347357
const PrecisionPoint startPoint = {
348358
state.lngX(startLatLng.longitude),
349359
state.latY(startLatLng.latitude),

0 commit comments

Comments
 (0)