CLLocation *lastLocation = [[CLLocation alloc] initWithLatitude:coords.latitude longitude:coords.longitude];
CLLocation *nowLocation = [[CLLocation alloc] initWithLatitude:location.coordinate.latitude longitude:location.coordinate.longitude];
int distanceMeters = [lastLocation distanceFromLocation:nowLocation];
if(appDelegate.isKMOrMILE == 0)
{
[cardistanceLabel setText:[NSString stringWithFormat:@"%d KM",distanceMeters/1000]];//公里
}
else if(appDelegate.isKMOrMILE == 1)
{
int data = (distanceMeters/1000)/1.6093;
[cardistanceLabel setText:[NSString stringWithFormat:@"%d MILE",data]];//英里
}
网友评论