问题
I am trying to find direction between two location using iOS framework but I am not able to find proper solution .
回答1:
You can use different methods for finding the direction between two location.
(1) Using Google Maps
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", currentLatitude, currentLongitude, destinationLatitude, destinationLongitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
(2) Using Apple Maps:
NSString *urlString = [NSString stringWithFormat:@"http://maps.apple.com/maps?saddr=%f,%f&daddr=%f,%f", currentLatitude, currentLongitude, destinationLatitude, destinationLongitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
Please let me know if you need any help.
回答2:
your question is not very clear, but i think you mean the bearing between two locations. see this question: Calculating bearing between two CLLocationCoordinate2Ds
回答3:
If your points are close together just use trigonometry. That will be close enough. If they are farther away then you want a great circle course, use the Haversine formula.
来源:https://stackoverflow.com/questions/25809300/how-to-find-direction-between-two-location-in-iphone-application