2012-11-02 38 views

回答

1

我相信最簡單的方法是使用Android Location類中的distanceBetween函數。

Location userLocation = new Location(); 
GeoPoint geoPoint = new GeoPoint(); 
float[] results = new float[3]; 
Location.distanceBetween(userLocation.getLatitude(), userLocation.getLongitude(), (geoPoint.getLatitudeE6()/1E6), (geoPoint.getLongitudeE6()/1E6), results); 
//result[0] = distance in m 
+0

偉大的解決方案!謝謝) – user1464440

1

這是一個簡單的數學方程。請參閱Euclidean Distance

確保您的單位有意義。如果沒有庫函數來執行此操作,則編碼完全是微不足道的。

1

Openmap是一個使用地圖構建應用程序的庫。它具有用於兩點之間的距離和方位角計算的類和方法。見類Geo

如果庫太大,可以從svn下載源文件並僅複製類Geo及其依賴項。