2012-04-26 58 views
0

我是Android和Java新手,在嘗試發送變量時遇到了創建GeoPoint的麻煩,但是當我發送一個字面值時,它很好。當傳遞變量時,GeoPoint不能正常工作

在下面的代碼塊,所述的烤麪包消息顯示正確的緯度(來自的strings.xml檢索

如何可以使用變量I設定緯度?

Integer intLat = Integer.valueOf(R.string.MexCityLat); 
Toast.makeText(HelloGoogleMapsActivity.this, intLat, Toast.LENGTH_SHORT).show(); 

GeoPoint point = new GeoPoint(intLat , -99120000); //this puts my point near North Pole 
//GeoPoint point = new GeoPoint(19240000, -99120000); //this puts my point in Mexico City 

OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!"); 
+0

你檢查了什麼是intLat的值是正確的值你得到 – 2012-04-26 02:15:42

回答

0

的GeoPoint

public GeoPoint(int latitudeE6,int longitudeE6) 

構造一個具有給定經度和緯度的GeoPoint,以微點(度* 1E6)度量。

參數:

latitudeE6 - The point's latitude. This will be clamped to between -80 degrees and +80 degrees inclusive, in order to maintain accuracy in the Mercator projection. 
longitudeE6 - The point's longitude. This will be normalized to be greater than -180 degrees and less than or equal to +180 degrees. 

也可參考此link如何雙轉換,浮到的GeoPoint。並確保你得到正確的價值intLat

+0

謝謝。我真正的問題是我沒有得到intLat的正確值。我改變了: – 2012-04-26 03:07:37

+0

問題是intLat有錯誤的值。我沒有正確讀取資源文件。我認爲它現在對我有用。 – 2012-04-26 03:15:48

+0

好,您的問題已解決 – 2012-04-26 03:19:02