检测region是否合规

phiz_2.43.5.2
Sean 2024-04-12 13:40:48 +08:00
parent 32dca4b673
commit 46fb1aa9d0
1 changed files with 9 additions and 0 deletions

View File

@ -199,6 +199,15 @@ static NSString *kUserAnnotationId = @"FATUserAnnotationViewId";
CLLocationCoordinate2D centerCoord = {[self judgeLatition:[self.latitude doubleValue]], [self judgeLongitude:[self.longitude doubleValue]]};
MKCoordinateRegion region = MKCoordinateRegionMake(centerCoord, MKCoordinateSpanMake(LongitudeDelta, LongitudeDelta));
CLLocationCoordinate2D center = region.center;
MKCoordinateSpan span = region.span;
if (center.latitude < -90 || center.latitude > 90 ||
center.longitude < -180 || center.longitude > 180) {
return ;
}
if (span.latitudeDelta <= 0 || span.longitudeDelta <= 0) {
return ;
}
[self.mapView setRegion:region animated:YES];
}