summaryrefslogtreecommitdiff
path: root/src/mbgl/map/transform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/map/transform.cpp')
-rw-r--r--src/mbgl/map/transform.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 45386b9dc8..d3cd30a627 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -660,7 +660,21 @@ void Transform::setGestureInProgress(bool inProgress) {
ScreenCoordinate Transform::latLngToScreenCoordinate(const LatLng& latLng) const {
if (!latLng) return {};
- ScreenCoordinate point = state.latLngToScreenCoordinate(latLng);
+
+ // If the center and point coordinates are not in the same side of the
+ // antimeridian, we need to unwrap the point longitude to make sure it can
+ // still be seen from the visible side of the antimeridian that is opposite
+ // to the center side.
+ double longitude = latLng.longitude;
+ const double centerLng = getLatLng().longitude;
+ if (centerLng - latLng.longitude > util::LONGITUDE_MAX) {
+ if (centerLng > 0 && latLng.longitude < 0) {
+ longitude += util::DEGREES_MAX;
+ } else if (centerLng < 0 && latLng.longitude > 0) {
+ longitude -= util::DEGREES_MAX;
+ }
+ }
+ ScreenCoordinate point = state.latLngToScreenCoordinate({ latLng.latitude, longitude });
point.y = state.height - point.y;
return point;
}