Updating the getDistanceFrom between two annotations in MapKit

Posted by Krismutt on Stack Overflow See other posts from Stack Overflow or by Krismutt
Published on 2010-12-26T23:55:36Z Indexed on 2010/12/27 0:53 UTC
Read the original article Hit count: 249

Hey everybody! I wanna have a UILabel that shows the distance between two annotations... but how do I get it to update the distance each time the current location is updated (location)??

CLLocationCoordinate2 savedPlace = savedPosition;
CLLocationCoordinate2D currentPlace = location;

    CLLocation *locCurrent = [[CLLocation alloc] initWithLatitude:currentPlace.latitude longitude:currentPlace.longitude];
    CLLocation *locSaved = [[CLLocation alloc] initWithLatitude:savedPlace.latitude longitude:savedPlace.longitude];

    CLLocationDistance distance = [locSaved distanceFromLocation:locCurrent];
    [showDistance setText:[NSString stringWithFormat:@"%g", distance]];

Thanks in advance!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about mapkit