2012-10-30 34 views
1

我正在構建一個計算燃料消耗的應用程序,我想知道計算兩個地點之間最短路線的最佳方式是什麼。我只需要以公里或英里爲單位的距離,而不需要地圖界面。iOS5:如何計算最短的汽車路線

在此先感謝

回答

-1

只要使用這個

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; 
+0

它看起來好像他想要「汽車路線」,這意味着某種與地圖的整合(雖然實際上不顯示地圖) –

+0

這是兩個地點之間的距離,通過跟蹤曲線之間的一條直線地球的。 – alecail

+0

啊我的錯誤,沒有正確閱讀 – AdamM