我正在构建一个计算油耗的应用程序,我想知道计算两个地点之间最短汽车路线的最佳方法是什么。我只需要以公里或英里为单位的距离,不需要地图界面。
提前感谢
发布于 2012-10-30 23:41:47
最简单的方法可能是与Google Maps API集成。
查看此处:https://developers.google.com/maps/documentation/directions/#DirectionsRequests
总之,您将向包含起始/结束位置的URL发出HTTP请求,并收到详细说明路由的JSON或XML。如果你只对距离感兴趣,你可以很容易地抓住总距离或时间。
发布于 2012-10-30 23:28:54
就用这个吧
CLLocation *loc = [[CLLocation alloc] initWithLatitude:someLatitude longitude:someLongitude];
CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:anotherLatitude longitude:anotherLongitude];
CLLocationDistance dist = [loc distanceFromLocation:loc2];
float fMiles = dist/1600;https://stackoverflow.com/questions/13142180
复制相似问题