문제

I'm currently working on an app that uses CLLocationManager with the lowest accuracy (kCLLocationAccuracyThreeKilometers). However, once every couple minutes I need to get an accurate location of the user, so I set the accuracy to kCLLocationAccuracyBest when a timer expires.

Obviously, CLLocationManager starts updating the location, going from an inaccurate location to more accurate locations in steps. The problem is, however, that I don't know how to detect when the optimal location accuracy has been reached, so I never know when I have the best location to work with.

Does anybody know a solution to this problem? It would be highly appreciated.

도움이 되었습니까?

해결책

IN the CLLocationManagerDelegate method locationManager:didUpdateLocations: look at the horizontalAccuracy of CLLocation. This will give you the radius in meters.

As stated in documentation:

The radius of uncertainty for the location, measured in meters. (read-only)

The location manager will keep trying in getting the best accuracy as possible, so you will have to decide when the location is accurate enough.

다른 팁

Similar functionality is implemented in detail by Apple in the sample project "LocateMe". Check out GetLocationViewController from LocateMe here: https://developer.apple.com/library/ios/samplecode/locateme.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top