LBS Project

需要一个MKMapView,作为显示地图。然后还需要使用CLLocationManager,来管理location。

CLLocation,CLLocationCoordinate2D这两个是位置的一些参数,和CLLocationManager配合使用。

MKCoordinateRegion,MKAnnotation,这两个,一个是用来设置mapview的region,一个是用来显示annotation,和mapview一同使用。

该project中,主要掌握几个点

1.定位无效问题

2.toobar的一些使用

3.初始化地图区域问题

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray*)locations{

CLLocation *location = [locations lastObject];

MKCoordinateRegion region;

float zoomLevel = 4000;

region = MKCoordinateRegionMakeWithDistance(location.coordinate, zoomLevel, zoomLevel);

self.mapView.centerCoordinate = location.coordinate;

[self.mapView setRegion:region animated:YES];

}

如果上述方法,会产生很大的问题,即地图无法移动的问题,因为每个位置的改动,都会运行上述代码,将地图固定在当前位置。

4.kCLErrorDenied 这个错误,一般是定位权限问题,可以在Settings -> General ->Reset中进行

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容