iPhone-中心地图,直到完全准确为止
|
我正在制作一个应用程序,打开它时,我开始获取用户位置并将地图居中放置在用户位置:
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
那我有
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
location = newLocation.coordinate;
if (isOpening) {
//Center location and set zoom on user when opening the app
MKCoordinateRegion region;
region.center = location;
//Set Zoom level using Span
MKCoordinateSpan span;
span.latitudeDelta = .005;
span.longitudeDelta = .005;
region.span = span;
isOpening = NO;
[mapView setRegion:region animated:TRUE];
}
}
使用isOpening标志,地图会在获得完全准确性之前停止居中,但如果我未设置标志,则地图将一遍又一遍地居中。有没有一种方法可以获取位置并完全准确地对中地图,然后停止对中?
没有找到相关结果
已邀请:
1 个回复
膝垫富顷