在iOS5中准确查找用户位置的方法



我需要在iPhone中查找用户位置。我能够使用CLLocation Manager找到用户的当前位置。但是我得到的位置与我的物理设备位置不准确。我使用了以下标准来设置的准确性

    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    locationManager.delegate = self;
    locationManager.distanceFilter = 10;
    [locationManager startMonitoringSignificantLocationChanges];
    [locationManager release];

当我尝试在locationManager:didUpdateToLocation:fromLocation:方法中打印"newLocation.verticalAccuracy"one_answers"newLocation.horizontalAccuracy"时,大多数时候我得到的水平精度约为10000,垂直精度约为12.00000。

那么,有没有其他方法可以更准确地找到用户位置,或者我错过了任何设置?请帮忙。

仅供参考:我正在使用WiFi,并在开放的地方进行测试,以获得更好的结果。

查看此链接

LocateMe示例演示项目

或者使用这个

放入你的.h文件

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface yourController : UIViewController <CLLocationManagerDelegate> {
    CLLocationManager *locationManager;
}
@end

和.m文件

在初始化方法中

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];

并使用此函数。。

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    NSLog(@"OldLocation %f %f", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
    NSLog(@"NewLocation %f %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude);
}

最新更新