Tag: 距离

如何计算用户移动时从用户位置到注释的距离

我有一个用户位置(蓝点)和mapView注释。 当select注释时,我将文本设置为distLabel – “到点%4.0f m的距离”。 用户移动时如何更新该文本标签? didSelectAnnotationView: – (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view { CLLocation *pinLocation = [[CLLocation alloc] initWithLatitude: [(MyAnnotation*)[view annotation] coordinate].latitude longitude: [(MyAnnotation*)[view annotation] coordinate].longitude]; CLLocation *userLocation = [[CLLocation alloc] initWithLatitude: self.mapView.userLocation.coordinate.latitude longitude: self.mapView.userLocation.coordinate.longitude]; CLLocationDistance distance = [pinLocation distanceFromLocation:userLocation]; [distLabel setText: [NSString stringWithFormat:@"Distance to point %4.0f m.", distance]]; } 我知道有一个函数didUpdateToLocation ,但我怎样才能用它didSelectAnnotationView ? – (void)locationManager:(CLLocationManager […]

如何找出坐标之间的距离?

我想让它显示两个CLLocation坐标之间的距离。 有没有一个复杂的math公式做到这一点? 如果没有一个公式你会怎么做?