2011-10-04 155 views
0

我有一個應用程序使用地圖來顯示某個固定的位置。隨着下一次更新,我想顯示從用戶當前位置到這個固定點的路線。我已經設法通過myLocationOverlay獲取用戶位置。
據我所知,我需要將座標發送到谷歌地圖,接收一個包含點的.kml文件並從中提取路線。我如何從myLocationOverlay獲取緯度和經度的值,或者有更好的方法來做我想做的事情?
TIA從Android的myLocationOverlay獲取座標值

回答

0

您可以使用getMyLocationMyLocationOverlay。然後您需要將GeoPoint轉換爲經度和長度各自的程度。

以下是Geo.java的參考文獻,其中包含一些可用於將GeoPoint轉換爲相應的經度和緯度的功能。特別是要使用這兩個:

public static Location toLocation(GeoPoint point) { 
    Location result = new Location(""); 
    result.setLatitude(toDegrees(point.getLatitudeE6())); 
    result.setLongitude(toDegrees(point.getLongitudeE6())); 
    return result; 
    } 

而且

/** 
    * Convert microdegrees to degrees. 
    * @param degreesE6 Value in microdegrees. 
    * @return Value in degrees. 
    */ 
    public static double toDegrees(int degreesE6) { 
    return (double) degreesE6/E6; 
    }