-1
私は特定のアドレスの経度と緯度を取得するために、volleyライブラリを使用しようとしています。アドレスは正常に取得できましたが、緯度と経度の値は取得できません。ボレーを使用してJSONから緯度と経度を取得するにはどうすればよいですか?
String googleMapUrl = "http://maps.googleapis.com/maps/api/geocode/json?address="+ place + "&sensor=false";
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, googleMapUrl, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
Toast.makeText(MainActivity.this, "Response "+ response, Toast.LENGTH_SHORT).show();
// JSONArray res = o.getJSONArray("results");
for (int i = 0; i < response.length(); i++) {
//JSONObject jsonObj = new JSONObject(result.toString());
//JSONArray resultJsonArray = jsonObj.getJSONArray("results");
JSONObject jsonObj = (JSONObject) response.get("i");
JSONObject resultJsonArray = jsonObj.getJSONObject("results");
// Extract the Place descriptions from the results
// resultList = new ArrayList<String>(resultJsonArray.length());
JSONObject before_geometry_jsonObj = resultJsonArray.getJSONObject("0");
JSONObject geometry_jsonObj = before_geometry_jsonObj
.getJSONObject("geometry");
JSONObject location_jsonObj = geometry_jsonObj
.getJSONObject("location");
String lat_helper = location_jsonObj.getString("lat");
lat = Double.valueOf(lat_helper);
String lng_helper = location_jsonObj.getString("lng");
lng = Double.valueOf(lng_helper);
どうすればよいですか?
それを解決し、あなたは正確にあなたが緯度と経度を取得されていませんと何を意味するのですか?あなたの意見は何ですか? –
場所の入力は、ユーザーから取得される場所のアドレスです。 – John
例を挙げて、私の最初の質問にも答えることができますか?経度と緯度の結果はどうなりますか? –