GoogleプレイスのURLから緯度と経度を文字列として取得しています。次に、取得した座標を使用して地図上にピンを配置したいと思います。GeoPointの文字列を整数に解析しようとしているため、何かがおかしなことになります。結果は0,0と表示されるため、ピンはアフリカの海岸から離れた場所に配置されます。これが私のコードです:
int lati5Int, longi5Int;
String latiString = in.getStringExtra(TAG_GEOMETRY_LOCATION_LAT);
String longiString = in.getStringExtra(TAG_GEOMETRY_LOCATION_LNG);
TextView getLatiStringtv.setText(latiString);
TextView getLongiStringtv.setText(longiString);
try {
lati5Int = Integer.parseInt(getLatiStringtv.getText().toString());
longi5Int = Integer.parseInt(getLongiStringtv.getText().toString());
} catch(NumberFormatException nfe) {
System.out.println("Could not parse " + nfe);
}
// shows that the ints are zeros
doubleLatiTV.setText(Integer.toString(lati5Int));
doubleLongiTV.setText(Integer.toString(longi5Int));
//--- GeoPoint---
newPoint = new GeoPoint(lati5Int,longi5Int);
mapController.animateTo(newPoint);
mapController.setZoom(17);
//--- Place pin ----
marker = getResources().getDrawable(R.drawable.malls);
OverlayItem overlaypoint = new OverlayItem(newPoint, "Boing", "Whattsup");
CustomPinpoint customPin = new CustomPinpoint(marker, SMIMap.this);
customPin.insertPinpoint(overlaypoint);
overlayList.add(customPin);
エラーは整数の解析にあると思います。
lati5Int = Integer.parseInt(getLatiStringtv.getText().toString());
longi5Int = Integer.parseInt(getLongiStringtv.getText().toString());
構文解析では、座標の小数点が表示され、異常が発生すると思います。では、GeoPointが座標文字列を30.487263、-97.970799のように正しくフォーマットされた座標として表示するように、座標文字列を整数に解析するにはどうすればよいですか。