1
Google지도의 JSON 응답은 다음과 같습니다. 시작과 목적지로 두 개의 우편 번호를 부여했습니다. 파트가 작동하도록 응답의 경로를 설명합니다. 응답에서 경도와 위도를 구하여 각지도를로드 할 수 있습니다. 내가 가지고있는 문제는 "북동"속성을 찾을 수 없다는 것입니다. 어떤 아이디어입니까?JSON 출력에서 위도/경도 값을 가져올 수 없습니다.
02-05 18:50:03.668: E/*********HelloviewActivity(10381): response code OK
02-05 18:50:03.673: E/*********HelloviewActivity(10381): {
02-05 18:50:03.673: E/*********HelloviewActivity(10381): "routes" : [
02-05 18:50:03.673: E/*********HelloviewActivity(10381): {
02-05 18:50:03.673: E/*********HelloviewActivity(10381): "bounds" : {
02-05 18:50:03.673: E/*********HelloviewActivity(10381): "northeast" : {
02-05 18:50:03.678: E/*********HelloviewActivity(10381): "lat" : 53.654430,
02-05 18:50:03.678: E/*********HelloviewActivity(10381): "lng" : -1.778250
02-05 18:50:03.678: E/*********HelloviewActivity(10381): },
02-05 18:50:03.678: E/*********HelloviewActivity(10381): "southwest" : {
02-05 18:50:03.683: E/*********HelloviewActivity(10381): "lat" : 53.62041000000001,
02-05 18:50:03.683: E/*********HelloviewActivity(10381): "lng" : -1.831710
02-05 18:50:03.683: E/*********HelloviewActivity(10381): }
02-05 18:50:03.683: E/*********HelloviewActivity(10381): },
.
String jsonOutput = response.toString();
// Log.e(TAG,"jsonOutput = " + jsonOutput);
JSONObject results = null;
try {
results = new JSONObject(jsonOutput);
routes = results.getJSONArray("routes");
bounds = routes.getJSONObject(0);
northeast = bounds.getJSONObject("northeast");
lat = Double.parseDouble((String) northeast.get("lat"));
lon = Double.parseDouble((String) northeast.get("lng"));
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.e(TAG, "lon/lat = "+lon +" "+lat);
.
02-05 18:50:04.668: W/System.err(10381): org.json.JSONException: JSONObject["northeast"] not found.
감사 이봐 지금 작동을 :) – turtleboy