1 今天做地图定位,发现出现这个问题 ,调用以下函数,出现问题MKCoordinateRegion region = MKCoordinateRegionMake(_currentLocationCoordinate, MKCoordinateSpanMake(zoomLevel, zoomLevel)); [_mapView setRegion:[_mapView regionThatFits:region] animated:YES];Exception : 'Invalid Region' when trying to display the map
2 度娘了一下,原来是超出范围了,加上范围判断
if ( (region.center.latitude >= -90) && (region.center.latitude <= 90) && (region.center.longitude >= -180) && (region.center.longitude <= 180) ){ [_mapView setRegion:[_mapView regionThatFits:region] animated:YES]; } else{ NSLog(@"invilid region"); }
3 究其根本,数据出错,后来找了原因,latitude 118,错了,已经超过范围-90<=latitude<=90-180<=longtitude<=180