检测region是否合规
parent
32dca4b673
commit
46fb1aa9d0
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue