2012-04-05 59 views
1

如何將Latitud和Longitud轉換爲Google GeoPoint?如何將Latitud和Longitud轉換爲Google GeoPoint?

我Latitud是:47.523009954564536 我的龍是:19.01667991207027

,當我嘗試轉換爲GeoPoints有:

GeoPoint point = new GeoPoint((int)(latitude * 1e6), 
           (int)(longitude * 1e6)); 

結果是: 4.7523009E7 1.901671E7

這顯然是錯誤的原因,我不打字從幾內亞灣(非洲) 我需要價值撻與47和19整數不是4和1. decim阿爾斯。

我在很多頁面看到了這種轉換,但不知何故它對我不好。 請幫忙!

回答

1

有可能是鑄造錯誤,嘗試使用這種方法:

public static GeoPoint calculateGeoPoint(double latitude, double longitude) { 
    Double latE6 = latitude * 1E6; 
    Double lngE6 = longitude * 1E6; 
    return new GeoPoint(latE6.intValue(), lngE6.intValue()); 
} 

this post

感謝服用。

+0

媽..相同的結果。也許我的拉丁語和longtidue有問題 – 2012-04-05 12:40:05

+0

你的經緯度是否指向匈牙利? – 2012-04-05 12:41:32

+0

嘗試刪除一些尾部數字,並將這兩個數字保留在小數點後6位。 – 2012-04-05 12:49:29

0
GeoPoint = new GeoPoint((int)(22.30 * 1E6),(int)(70.80 * 1E6)); 

試試這個它的工作原理...