显示自己的位置:
1,在属性检查器里勾选show user location
2,或者通过_mapView.showsUserLocation = YES将属性设置为YES;
3,self.map.mapType = MKMapTypeStandard;
self.map.mapType = MKMapTypeSatellite;
self.map.mapType = MKMapTypeHybrid;
设置地图样式
CLLocationManager使用时的基本设置:
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;设置多远距离刷新一次位置
开启定位功能:[_locationManager startUpdatingLocation];
关闭定位功能:[_locationManager stopUpdatingLocation];
设置地图显示比率:[_mapView setRegion:region animated:YES];
到某个位置的距离[newLocation distanceFromLocation:_startPoint];
error.code == kCLErrorDenied判断刷新失败的原因是不是用户拒绝开启定位功能 ,未知原因为kCLErrorLocationUnknown
老师为显示的问题是因为
if (newLocation.verticalAccuracy < 0 || newLocation.horizontalAccuracy < 0) {
// invalid accuracy
return;
}
if (newLocation.horizontalAccuracy > 100 || newLocation.verticalAccuracy > 50) {
// accuracy radius is so large, we don't want to use it
return;
}
这个判断语句,导致了大头钉位置标签未显示