How to find direction between two location in iPhone application?

冷暖自知 提交于 2019-12-08 04:18:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!