Skip to content

Commit

Permalink
Add LatLngBounds.pad() method
Browse files Browse the repository at this point in the history
A similar method of the same name was removed in fleaflet#1427.

This method simply expands the LatLngBounds coordinates by
latitude and longitude constants.

Checks to ensure the adjustment remains "in-bounds" is performed,
similar to the extend and extendBounds methods.
  • Loading branch information
Adam Brewer committed Sep 13, 2024
1 parent 7632ccc commit 30ab50f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/src/geo/latlng_bounds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ class LatLngBounds {
west = max(minLongitude, min(west, bounds.west));
}

/// Expands bounding box by [latitude] and [longitude]. This method mutates
/// the bounds object on which it is called.
void pad(double latitude, double longitude) {
north = min(maxLatitude, north + latitude);
south = max(minLatitude, south - latitude);
east = min(maxLongitude, east + longitude);
west = max(minLongitude, west - longitude);
}

/// Obtain coordinates of southwest corner of the bounds.
///
/// Instead of using latitude or longitude of the corner, use [south] or
Expand Down

0 comments on commit 30ab50f

Please sign in to comment.