안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요 안드로이드 공부중인데요.
getIntent로 위도, 경도를 넘겨받았는데요
Intent intent = getIntent();
final String strLat = intent.getStringExtra("Lat");
final String strLon = intent.getStringExtra("Lon");
이런식으로요..
위도는 strLat, 경도는 strLon에 저장이 되있습니다.
이 변수을 GeoPoint()에 넣을려고 그러는데 어떻게 해야하나요...

2011.08.24 23:10:25
위,경도 문자열이 32.8394 123.93959 식으로 되어있는거면
Double.parse 로.. double 로 바꾼다음에 아래 메소드를 사용하세요.
protected GeoPoint convertToGeoPoint(double lat, double lng) {
return new GeoPoint((int)(lat * 1E6), (int)(lng * 1E6));
}
protected double[] convertToLatLng(GeoPoint geo) {
double[] latlng = new double[2];
latlng[0] = geo.getLatitudeE6() / 1e6;
latlng[1] = geo.getLongitudeE6() / 1e6;
return latlng;
}



