获得MKMapView位置的准确性

时间:2012-02-14 13:51:48

标签: iphone ios mkmapview userlocation

我想知道是否有办法从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");
    }    
}

圆圈通常用小圆圈包裹它来表示位置的准确性,因此显然会发送精确度。

感谢您提供的任何帮助。

2 个答案:

答案 0 :(得分:1)

horizontalAccuracy中的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

答案 1 :(得分:0)

这个委托方法是否完全被调用?确保已为showsUserLocation实例

MKMapView设置为YES