I am zooming out the map on the click of the button.
So when the map is fully zoomed out and if I try to again zoom out it then it crashes while setting the region.
Not sure but, Is there any way out to detect if the map has reached it maximum zoom limit?
Here is my code to zoom out the map
-(void)setZoomLevelForNoPicksCurrentLocationAt:(CLLocationCoordinate2D)currentCoordinate{
MKCoordinateSpan span;
MKCoordinateRegion region;
region.center = currentCoordinate;
span.latitudeDelta =self.mapView.region.span.latitudeDelta *2;
span.longitudeDelta =self.mapView.region.span.longitudeDelta *2;
region.span = span;
[self.mapView setRegion:region animated:YES];
[self.mapView regionThatFits:region];
}
Any kind of help will be really appreciated.
Please find the crash log
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region center:+38.82259098, -67.50000000 span:+307.41536753, +450.00000000' * Call stack at first throw: ( 0 CoreFoundation 0x013c8be9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x0151d5c2 objc_exception_throw + 47 2 CoreFoundation 0x013c8b21 -[NSException raise] + 17 3 XXXapp 0x000ab237 -[MapViewController setZoomLevelForNoPicksCurrentLocationAt:] + 312
The minimum span value u can provide is 0.0 . At run-time the value of span is getting negative which causes the crash. Just hard cord and try and put a nslog to monitor the value of span. The maximum span value is 180.0 above that will result in crash.