views:

47

answers:

1

Hi All,

I'm need to detect small location change for the iphone , I tried the sample that's called Locate Me, but it doesn't recognize the small change in the location. Is there any way for doing this?

Thanks in Advance.

Best regards John

A: 

Hi John,

How small is the change that you expected?

Maybe you should set the accuracy to it's maximum and calculate the displacement on the delegate method.

Configure the location manager to give you it's best.


    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
    [locationManager setDistanceFilter:0.0];

And then on the delegate method:


- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    // Calculate the distance between the two locations
    CGFloat distance = [newLocation distanceFromLocation:oldLocation];

    if (distance >= MIN_DISPLACEMENT) {
        // Do something
    } else {
        // Do something
    }
}

To get more accurate data from the location manager, set the proper keys for UIRequiredDeviceCapabilities (location-services, gps) on the Info.plist.

vfn
@vfn, i tried this solution, but i need the distance to be updated in the real time, GPS requires time to get the distance travelled which is not suitable in my app.
John Nabil
@John, if you need real time updates you would need to take advantage of the accelerometer or (on iOS4) http://developer.apple.com/iphone/library/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MotionEvents/MotionEvents.html#//apple_ref/doc/uid/TP40009541-CH4-SW26
vfn