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

Commit

Permalink
[core] Fly across the meridian or antemeridian, whichever is shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Dec 20, 2015
1 parent af9de6c commit 97c143a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/mbgl/map/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 97c143a

Please sign in to comment.