diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2017-08-10 15:07:48 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2017-08-19 11:29:38 +0200 |
commit | 2802c55bd5e4f104fee991cb944e4d2503cbb18d (patch) | |
tree | 74121aef90d60dbd6cf79663b4c03e45038f0fa4 /platform/android/MapboxGLAndroidSDK/src | |
parent | b4cb719ceba57b5b2879d54473531c3404a20c77 (diff) | |
download | qtlocation-mapboxgl-2802c55bd5e4f104fee991cb944e4d2503cbb18d.tar.gz |
[android] - create smallest possible LatLngBounds when visible region crosses the dateline
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src')
2 files changed, 17 insertions, 8 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java index 505b2db192..8b2ccffef1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java @@ -222,6 +222,16 @@ public class LatLngBounds implements Parcelable { } /** + * Constructs a LatLngBounds from doubles representing a LatLng pair. + * <p> + * This method doesn't recalculate most east or most west boundaries. + * </p> + */ + public static LatLngBounds from(double latNorth, double lonEast, double latSouth, double lonWest) { + return new LatLngBounds(latNorth, lonEast, latSouth, lonWest); + } + + /** * Constructs a LatLngBounds from current bounds with an additional latitude-longitude pair. * * @param latLng the latitude lognitude pair to include in the bounds. diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java index e0a634521b..3841809a65 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java @@ -78,8 +78,6 @@ public class Projection { * @return The projection of the viewing frustum in its current state. */ public VisibleRegion getVisibleRegion() { - LatLngBounds.Builder builder = new LatLngBounds.Builder(); - float left = 0; float right = nativeMapView.getWidth(); float top = 0; @@ -90,12 +88,13 @@ public class Projection { LatLng bottomRight = fromScreenLocation(new PointF(right, bottom)); LatLng bottomLeft = fromScreenLocation(new PointF(left, bottom)); - builder.include(topLeft) - .include(topRight) - .include(bottomRight) - .include(bottomLeft); - - return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight, builder.build()); + return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight, + LatLngBounds.from( + topRight.getLatitude(), + topRight.getLongitude(), + bottomLeft.getLatitude(), + bottomLeft.getLongitude()) + ); } /** |