1 今天做地图定位,发现出现这个问题 ,调用以下函数,出现问题
MKCoordinateRegion region = MKCoordinateRegionMake(_currentLocationCoordinate, MKCoordinateSpanMake(zoomLevel, zoomLevel)); [_mapView setRegion:[_mapView regionThatFits:region] animated:YES];
Exception
: ‘Invalid Region <center:+inf, +0.00000000 span:+1.00000000, +0.50000000>‘ 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
版权声明:本文为博主原创文章,未经博主允许不得转载。
地图定位出错Exception : 'Invalid Region
时间: 2024-09-29 09:50:03