2

我想知道是否有办法从 MKMapView 获取接收到的位置的准确性。

我原以为下面的代码会起作用,但事实并非如此。我也可以直接登录该属性吗?

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {    

    if (userLocation.location.horizontalAccuracy == kCLLocationAccuracyBest) {
        NSLog(@"Best");
    }
    if (userLocation.location.horizontalAccuracy == kCLLocationAccuracyBestForNavigation) {
        NSLog(@"Best for nav");
    }
    if (userLocation.location.horizontalAccuracy == kCLLocationAccuracyHundredMeters) {
        NSLog(@"100m");
    }
    if (userLocation.location.horizontalAccuracy == kCLLocationAccuracyKilometer) {
        NSLog(@"km");
    }
    if (userLocation.location.horizontalAccuracy == kCLLocationAccuracyNearestTenMeters) {
        NSLog(@"10m");
    }
    if (userLocation.location.horizontalAccuracy == kCLLocationAccuracyThreeKilometers) {
        NSLog(@"3km");
    }    
}

一个圆圈通常代表一个位置的准确性,将其包裹在蓝色的小圆圈周围,因此显然正在发送准确性。

谢谢你的尽心帮助。

4

2 回答 2

1

horizontalAccuracyin 属性指示当前坐标 实例CLLocation精确度。

地图视图使用的不是“desiredAccuracy”(可以设置和读取的属性CLLocationManager)。据我所知,该设置在MKMapView.

但是,在 Breadcrumb 示例应用程序的BreadcrumbViewController.m文件中,有以下注释:

// Note: we are using Core Location directly to get the user location updates.
// We could normally use MKMapView's user location update delegation but this does not work in
// the background.  Plus we want "kCLLocationAccuracyBestForNavigation" which gives us a better accuracy.

所以这意味着MKMapView至少没有使用kCLLocationAccuracyBestForNavigation.

于 2012-02-14T14:14:29.810 回答
0

这个委托方法是否被调用?确保您已为实例设置showsUserLocation为 YESMKMapView

于 2012-02-14T14:04:47.123 回答