File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
maplibre_gl_platform_interface/lib/src Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,26 @@ class LatLngBounds {
8484 return < dynamic > [southwest.toJson (), northeast.toJson ()];
8585 }
8686
87+ /// Determines whether a given geographical point (`LatLng` ) is within the
88+ /// bounds defined by two other geographical points: `southwest` (lower-left corner)
89+ /// and `northeast` (upper-right corner).
90+ ///
91+ bool contains (LatLng point) {
92+ final isLatitudeInBounds = point.latitude >= southwest.latitude &&
93+ point.latitude <= northeast.latitude;
94+
95+ final bool isLongitudeInBounds;
96+
97+ if (southwest.longitude <= northeast.longitude) {
98+ isLongitudeInBounds = point.longitude >= southwest.longitude &&
99+ point.longitude <= northeast.longitude;
100+ } else {
101+ isLongitudeInBounds = point.longitude >= southwest.longitude ||
102+ point.longitude <= northeast.longitude;
103+ }
104+ return isLatitudeInBounds && isLongitudeInBounds;
105+ }
106+
87107 @visibleForTesting
88108 static LatLngBounds ? fromList (dynamic json) {
89109 if (json == null ) {
You can’t perform that action at this time.
0 commit comments