Updating the getDistanceFrom between two annotations in MapKit
- by Krismutt
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!