google maps - How to get latitude and longitude from JSON using volley? -


i trying use volley library longitude , latitude of particular address. though have been able address successfully, not getting latitude , longitude values.

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");                         (int = 0; < 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 place descriptions 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); 

how go this?

i solved way

        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();                      log.d("volley response ", string.valueof(response));                     lat = response.getjsonarray("results").getjsonobject(0).getjsonobject("geometry").getjsonobject("location").getdouble("lat");                     lng = response.getjsonarray("results").getjsonobject(0).getjsonobject("geometry").getjsonobject("location").getdouble("lng"); 

thanks michael contribution


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -