[android] - create smallest possible LatLngBounds when visible region crosses the dateline
This commit is contained in:
@@ -221,6 +221,16 @@ public class LatLngBounds implements Parcelable {
|
||||
return new LatLng[] {getNorthEast(), getSouthWest()};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
||||
@@ -93,8 +93,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;
|
||||
@@ -105,12 +103,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())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user