0
주석과의 거리를 계산하려하지만 어떤 이유로 주석 좌표를 얻을 수 없습니다. 내가 plist
에서 특수 효과를로드합니다.주석과의 거리를 계산할 수 없습니다.
CLLocationCoordinate2D annocoord = myAnnotation.coordinate;
CLLocationCoordinate2D usercoord = self.mapView.userLocation.coordinate;
NSLog(@"ANNO = %f, %f", annocoord.latitude, annocoord.longitude);
NSLog(@"USER = %f, %f", usercoord.latitude, usercoord.longitude);
CLLocation *loc = [[CLLocation alloc] initWithLatitude:myAnnotation.coordinate.latitude longitude:myAnnotation.coordinate.longitude];
CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:self.mapView.userLocation.coordinate.latitude longitude:self.mapView.userLocation.coordinate.longitude];
NSLog(@"LOC = %f, %f", loc.coordinate.latitude, loc.coordinate.longitude);
NSLog(@"LOC2 = %f, %f", loc2.coordinate.latitude, loc2.coordinate.longitude);
CLLocationDistance dist = [loc distanceFromLocation:loc2];
NSLog(@"DIST: %f", dist);
로그 :
ANNO = 0.000000, 0.000000
USER = 60.492631, 22.258933
LOC = 0.000000, 0.000000
LOC2 = 60.492631, 22.258933
DIST: 6999960.693412
이 방법은 장거리 용으로 만 사용할 수 있습니다. 장거리 전화로 작업하는 경우 2D 평면에서 작업 할 때 지구 원형도에 대처할 수 있도록 좀 더 복잡한 수식 ('distanceFromLocation'에서 구현)을 사용해야합니다 . – CitronEvanescent
확인. 조언 주셔서 감사합니다. –