How can I get the distance in meters between two CLLocation
s? CLLocation
doesn't provide any method to do it, it seeems.
CLLocationDistance distance = [aCLLocationA distanceFromLocation:aCLLocationB];
// distance is a double representing the distance in meters
CLLocationDistance distance = [secondLocation distanceFromLocation:firstLocation]; // distance is expressed in meters
CLLocationDistance kilometers = distance / 1000.0;
// or you can also use this..
CLLocationDistance meters = distance;
NSString *distanceString = [[NSString alloc] initWithFormat: @"%f", kilometers];
flot totaldistancecovered = [distanceString floatValue];
//Now,you can use this float value for addition...
// distanceMoved should be float type variable which is declare in .h file...
distanceMoved = distanceMoved + totaldistancecovered ;
theLabel.text = [NSString stringWithFormat: @"%f meters", distanceMoved];
Hope, this will help you...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With