Skip to content

Commit

Permalink
fix: fitBounds on iOS across 180th meridian (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiKilian authored Mar 10, 2025
1 parent be87619 commit 46645e1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ios/MLRN/CameraUpdateItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,15 @@ - (UIEdgeInsets)_clippedPadding:(UIEdgeInsets)padding forView:(MLRNMapView *)map
}

- (BOOL)_areBoundsValid:(MLNCoordinateBounds)bounds {
BOOL isValid =
CLLocationCoordinate2DIsValid(bounds.ne) && CLLocationCoordinate2DIsValid(bounds.sw);

if (!isValid) {
return NO;
if ([self _isLatitudeValid:bounds.ne.latitude] && [self _isLatitudeValid:bounds.sw.latitude]) {
return YES;
}

CLLocationCoordinate2D ne = bounds.ne;
CLLocationCoordinate2D sw = bounds.sw;
return [self _isCoordValid:ne] && [self _isCoordValid:sw];
return NO;
}

- (BOOL)_isLatitudeValid:(CLLocationDegrees)latitude {
return latitude >= -90 && latitude <= 90;
}

- (BOOL)_isCoordValid:(CLLocationCoordinate2D)coord {
Expand Down

0 comments on commit 46645e1

Please sign in to comment.