summaryrefslogtreecommitdiff
path: root/src/mbgl/map
diff options
context:
space:
mode:
authorPeng Liu <peng.liu@mapbox.com>2020-01-09 15:53:23 +0200
committerGitHub <noreply@github.com>2020-01-09 15:53:23 +0200
commit236afc03958cc729b3b8121a1c5a72660f0e9fa2 (patch)
treead7da4d786c7ef7ce0ee14ecacd303e5a3eb34f2 /src/mbgl/map
parentd3a5ed968cc5288c171404d5c3f8d16a552ff28a (diff)
downloadqtlocation-mapboxgl-236afc03958cc729b3b8121a1c5a72660f0e9fa2.tar.gz
[android][core] Add `Map::latLngBoundsForCameraUnwrapped` and jni binding for `getVisibleCoordinateBounds`. (#16069)
* [android] Add getVisibleCoordinateBounds method. * Fix Map::latLngBoundsForCamera, add Android binding for getVisibleRegionBounds. * Add unit tests for CameraToLatLngBoundsWithRotation and CameraToLatLngBoundsCrossDateLine. * Move API breaking changes to a new method name latLngBoundsForCameraUnwrapped.
Diffstat (limited to 'src/mbgl/map')
-rw-r--r--src/mbgl/map/map.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 9cd9fdc15f..a994af305f 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -256,6 +256,27 @@ LatLngBounds Map::latLngBoundsForCamera(const CameraOptions& camera) const {
);
}
+LatLngBounds Map::latLngBoundsForCameraUnwrapped(const CameraOptions& camera) const {
+ Transform shallow{impl->transform.getState()};
+ Size size = shallow.getState().getSize();
+
+ shallow.jumpTo(camera);
+ LatLng nw = shallow.screenCoordinateToLatLng({});
+ LatLng se = shallow.screenCoordinateToLatLng({double(size.width), double(size.height)});
+ LatLng ne = shallow.screenCoordinateToLatLng({double(size.width), 0.0});
+ LatLng sw = shallow.screenCoordinateToLatLng({0.0, double(size.height)});
+ LatLng center = shallow.screenCoordinateToLatLng({double(size.width) / 2, double(size.height) / 2});
+ nw.unwrapForShortestPath(center);
+ se.unwrapForShortestPath(center);
+ ne.unwrapForShortestPath(center);
+ sw.unwrapForShortestPath(center);
+ LatLngBounds bounds = LatLngBounds::hull(nw, se);
+ bounds.extend(ne);
+ bounds.extend(sw);
+ bounds.extend(center);
+ return bounds;
+}
+
#pragma mark - Bounds
void Map::setBounds(const BoundOptions& options) {