Reading Boolean from JSON - android

I use the following the json for my android app.
[
{
"id" : "001",
"firstName" : "Mark",
"lastName" : "Mason",
"role" : "CEO",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"teamName" : "iOS",
"members" : [
{
"id" : "002",
"firstName" : "Olly",
"lastName" : "Berry",
"role" : "iOS Team Lead",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png",
"teamLead" : true
},
{
"id" : "003",
"firstName" : "James",
"lastName" : "Frost",
"role" : "iOS Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "004",
"firstName" : "Liam",
"lastName" : "Nichols",
"role" : "iOS Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "005",
"firstName" : "Chris",
"lastName" : "Watson",
"role" : "iOS Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "006",
"firstName" : "Richard",
"lastName" : "Turton",
"role" : "iOS Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "007",
"firstName" : "Matt",
"lastName" : "Colliss",
"role" : "iOS Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "008",
"firstName" : "David",
"lastName" : "Gibson",
"role" : "iOS Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "009",
"firstName" : "Tom",
"lastName" : "Guy",
"role" : "iOS Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "010",
"firstName" : "Rich",
"lastName" : "Hodgkins",
"role" : "iOS Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
}
]
},
{
"teamName" : "Android",
"members" : [{
"id" : "011",
"firstName" : "David",
"lastName" : "Branton",
"role" : "Android Team Lead",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png",
"teamLead" : true
},
{
"id" : "012",
"firstName" : "Dre",
"lastName" : "Pilipczuk",
"role" : "Android Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "013",
"firstName" : "Ray",
"lastName" : "Britton",
"role" : "Android Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "014",
"firstName" : "Charly",
"lastName" : "Murillo",
"role" : "Android Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
}
]
},
{
"teamName" : "Web",
"members" : [{
"id" : "015",
"firstName" : "Ryan",
"lastName" : "French",
"role" : "Web Team Lead",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png",
"teamLead" : true
},
{
"id" : "016",
"firstName" : "James",
"lastName" : "Ward",
"role" : "Web Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "018",
"firstName" : "Adam",
"lastName" : "Smith",
"role" : "Web Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "019",
"firstName" : "Leonard",
"lastName" : "Da Costa",
"role" : "Web Developer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
}
]
},
{
"teamName" : "Design",
"members" : [{
"id" : "020",
"firstName" : "Hannah",
"lastName" : "Tempest",
"role" : "Design Team Lead",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png",
"teamLead" : true
},
{
"id" : "021",
"firstName" : "Ellis",
"lastName" : "Reed",
"role" : "Designer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "022",
"firstName" : "Pete",
"lastName" : "Horsham",
"role" : "Designer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "023",
"firstName" : "Hemel",
"lastName" : "Dave",
"role" : "Designer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
},
{
"id" : "024",
"firstName" : "Hannah",
"lastName" : "Corke",
"role" : "Designer",
"profileImageURL" : "http://developers.mub.lu/resources/profilePlaceholder.png"
}
]
}
]
I display those data sucessfully in a recyclerview. However,I want to highlight the row of the lead photographer. The lead photographer object has a "teamLead" object,and the others don't.
So if I set it to true.
for(int j=0;j<teamMembersArray.length();j++){
//The model class which contains the setters/getters
//in order to "deserialize" the JSON objects into string,int,boolean
//objects.
Model m = new Model();
JSONObject teamObject = teamMembersArray.getJSONObject(j);
m.setId(teamObject.getInt("id"));
//This line refers to ALL JSON OBJECTS!!! I want
//to read only those who had teamLead separately from
//the other objects.
if(teamObject.has("teamLead")){
m.setTeamLead(teamObject.getBoolean("teamLead"));
}else {
m.setId(teamObject.getInt("id"));
m.setProfileImageURL(teamObject.getString("profileImageURL"));
m.setFirstName(teamObject.getString("firstName"));
m.setLastName(teamObject.getString("lastName"));
m.setRole(teamObject.getString("role"));
//Finally I am adding the string objects into an ArrayList.
modelArrayList.add(m);
}
I get an exception saying that teamLeader JSONObject,doesn't exist. It is so confusing and messed up situation.
How can I fix that?
Thanks,
Theo.

exception saying that teamLead JSONObject,doesn't exist
Because teamLead key is not avalaible in all JSONObject's which is in teamMembersArray JSONArray.
So, to get it work add check for null before accessing value for teamLead key from JSONObject like:
if (teamObject.has("teamLead") && !teamObject.isNull("teamLead")) {
m.setTeamLead(teamObject.getBoolean("teamLead"));
}else{
m.setTeamLead(false); // set default value here
}

Related

Get data from Firebase database using child name from unknown push key

Using android studio ( android )
how to Get data from Firebase database
using child value from unknown pushed key
as you can see in the picture friends
I'm trying to get data where
topicimage4 = 0
But I don't have the random key Firebase pushed
Firebase database
I searched alot about this Issue but I didn't found anything or
I found questions with no answers in this website
I tried also the following
myRef.child("*").orderByChild("topicimage4").equalTo("0")
myRef.child("?").orderByChild("topicimage4").equalTo("0")
myRef.orderByChild("topicimage4").equalTo("0")
myRef.orderByKey().orderByChild("topicimage4").equalTo("0")
UPDATE
here my Json tree as text
Is there any way to access to the topicimage4 child without having the Randrom key ? thnx
{
"-L5YppUZa3dGBvDUgnYi" : {
"paidmoney" : "400",
"paidmoneytype" : "1",
"topiccat" : "1",
"topiccon" : "0",
"topicemail" : "",
"topicimage1" : "null",
"topicimage2" : "null",
"topicimage3" : "null",
"topicimage4" : "0",
"topicimage5" : "21",
"topicname" : "مطلوب انسات للعمل ضمن صالون نسائي طريق عام جزين",
"topicphone" : "70645725",
"topicresouresname" : "",
"topicresouresurl" : "",
"topictext" : "في حال طلب منك الاتصال دولار اضافي على الدقيقة قم بإغلاق الخط \r\n\r\nمطلوب انسات للعمل ضمن صالون نسائي طريق عام جزين\r\n\r\n\r\nنحن نحاول قدر الامكان ضبط جميع انواع الوظائف المقدمة نشكر لكم اهتمامكم ومساعدتكم\r\n",
"topictimed" : "17",
"topictimeh" : "01",
"topictimei" : "57",
"topictimem" : "02",
"topictimey" : "18",
"userimage" : "0"
},
"-L5Yq6VJoOAN7dUKDO9O" : {
"paidmoney" : "400",
"paidmoneytype" : "1",
"topiccat" : "1",
"topiccon" : "0",
"topicemail" : "",
"topicimage1" : "null",
"topicimage2" : "null",
"topicimage3" : "null",
"topicimage4" : "0",
"topicimage5" : "0",
"topicname" : "يلزمنا انسه ذات مظهر لائق",
"topicphone" : "81614696",
"topicresouresname" : "",
"topicresouresurl" : "",
"topictext" : "في حال طلب منك الاتصال دولار اضافي على الدقيقة قم بإغلاق الخط \r\n\r\nيلزمنا انسه زات مظهر لائق للعمل في اكس برس عالاوتستراد بدوام كامل للمراجعه وتس اب التفاصيل موجوده كامله\r\n\r\n\r\n\r\nنحن نحاول قدر الامكان ضبط جميع انواع الوظائف المقدمة نشكر لكم اهتمامكم ومساعدتكم\r\n",
"topictimed" : "17",
"topictimeh" : "01",
"topictimei" : "58",
"topictimem" : "02",
"topictimey" : "18",
"userimage" : "0"
}
}

Google API url for android returns ZERO_RESULTS

When I run the first Google API url with origin, destination and waypoints, it returns
https://maps.googleapis.com/maps/api/directions/json?origin=9.6614981,80.02554649999999&waypoints=6.9040322,79.948803&destination=6.053518500000001,6.053518500000001%7C&sensor=false
{
"geocoded_waypoints" : [
{},
{},
{
"geocoder_status" : "ZERO_RESULTS"
}
],
"routes" : [],
"status" : "NOT_FOUND"
}
But when I run this second url, this works perfectly fine.
https://maps.googleapis.com/maps/api/directions/json?origin=6.9146871,79.9711348&waypoint=6.9040322,79.948803%7C&destination=6.9058482,79.9248089&sensor=false
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJnbKVwttW4joR96eguc1D88A",
"types" : [ "route" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJnVoMvVZX4joRcAOUeZGMTUA",
"types" : [ "street_address" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 6.916328699999999,
"lng" : 79.972351
},
"southwest" : {
"lat" : 6.9033429,
"lng" : 79.9247644
}
},
"copyrights" : "Map data ©2017 Google",
"legs" : [
{
"distance" : {
"text" : "6.9 km",
"value" : 6928
},
"duration" : {
"text" : "18 mins",
"value" : 1109
},
"end_address" : "19/7 Bogahahena Rd, Sri Jayawardenepura Kotte 10120, Sri Lanka",
"end_location" : {
"lat" : 6.9058178,
"lng" : 79.9247644
},
"start_address" : "Pasan Mawatha, Malabe, Sri Lanka",
"start_location" : {
"lat" : 6.914893699999999,
"lng" : 79.9702508
},
"steps" : [
{
"distance" : {
"text" : "0.2 km",
"value" : 167
},
"duration" : {
"text" : "1 min",
"value" : 50
},
"end_location" : {
"lat" : 6.916328699999999,
"lng" : 79.97066389999999
},
"html_instructions" : "Head \u003cb\u003enorth\u003c/b\u003e on \u003cb\u003ePasan Mawatha\u003c/b\u003e toward \u003cb\u003eWelivita Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Boys Hostel (on the right)\u003c/div\u003e",
"polyline" : {
"points" : "aqei#aebgNg#GWEOEUKaAY{AWK?O?"
},
"start_location" : {
"lat" : 6.914893699999999,
"lng" : 79.9702508
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.2 km",
"value" : 202
},
"duration" : {
"text" : "1 min",
"value" : 42
},
"end_location" : {
"lat" : 6.915699,
"lng" : 79.972351
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eWelivita Rd\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "azei#sgbgNBg#BQHc#J[Va#LQHOFOLm#He#No#"
},
"start_location" : {
"lat" : 6.916328699999999,
"lng" : 79.97066389999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "2.8 km",
"value" : 2757
},
"duration" : {
"text" : "7 mins",
"value" : 426
},
"end_location" : {
"lat" : 6.903943,
"lng" : 79.9549985
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at Petti Kade onto \u003cb\u003eB263\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Super Como Technologies (on the right)\u003c/div\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "cvei#erbgN|#J`#DbAHb##hBFn#?t##^?rAAhAA\\AX?b#?R#RBTBPBPDXH\\H\\Jz#X|Cr#LFHBJDNHLDLHLJPJNLJNLNJRLTHTHV|#lC`#fAHTDPDPBJ#J#T#TAVAVCVIb#KZKVO\\KTM`#AJALALAN#RBZDZF^FZFVHPFPFNFDPRJHVNXLrAj#FBn#Zn#XXNVNTLPJXPXVd#b###PRZ`#JRL\\Rl#^`AJZDFXp#DLPd#Xn#JVNX\\j#b#p#^l#h#fA\\z#Pb#t#xBVp#ZhAVlANv#ZpADd#BZ#L#d##TANCTE^Gh#Mp#Qz#APIZI\\EZI`#Ef#Ej#Ef#Gz#Cd#"
},
"start_location" : {
"lat" : 6.915699,
"lng" : 79.972351
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "3.7 km",
"value" : 3722
},
"duration" : {
"text" : "9 mins",
"value" : 564
},
"end_location" : {
"lat" : 6.9052345,
"lng" : 79.9251951
},
"html_instructions" : "At \u003cb\u003eMalabe\u003c/b\u003e, continue onto \u003cb\u003eකෝට්ටේ - බෝපේ පාර\u003c/b\u003e/\u003cb\u003eB240\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Megacity (on the left in 350 m)\u003c/div\u003e",
"polyline" : {
"points" : "slci#we_gNEj#Cl#CPCTERKZM\\Ql#Wn#Wz#Oz#GZALAN?Z?N#L?HBPBVZnBD\\#L#J#L#H?J?F?HAH?HCFAHEJGLMZKV}#bBUb#s#jAm#jAKPKNOZARQd#Qp#M`#[hASr#a#~AYfA]dAM^CJEFMNOPOHi#Xc#Tc#X_#Tq#h#OLOPQROPEJKRELADERMl#I`#I^I`#APCL?JAP?N#H#RDPBJPh#FNDNFPBH#JBLBNBV?#D\\FrAD~#Bv##V?R?`#?^?`DAd#An#Cj#EzAAx#A`AAnA#`##T#TBPFPDNDNFPJVVv#N\\b#hAVr#JXHVFTFTJl#Ff#Fj#B^#V?Z?^?b#?n#ErDChAEl#C^G`#UpAMh#Q~#Ox#EX?TETCLAJAJ?L?H#H#FBDBFDDDFBBJHFBFFLJNFNBJ#RBN#J?V#p#BL#XDXFRFPFVJTLRLPNXTHJJJFNDN#L#NALCPERGVw#~DMf#EPABAJCPAN#L#LDPFLJPHFJHJHPHNLLH^V"
},
"start_location" : {
"lat" : 6.903943,
"lng" : 79.9549985
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "80 m",
"value" : 80
},
"duration" : {
"text" : "1 min",
"value" : 27
},
"end_location" : {
"lat" : 6.9058178,
"lng" : 79.9247644
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at okvel auto care onto \u003cb\u003eBogahahena Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Waruna Motors (on the left)\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "utci#okyfNc#\\IFgAp#"
},
"start_location" : {
"lat" : 6.9052345,
"lng" : 79.9251951
},
"travel_mode" : "DRIVING"
}
],
"traffic_speed_entry" : [],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "aqei#aebgN_AMe#QaAY{AW[?Fy#T_Ad#s#P_#VsANo#|#JdBNlCHxE?dDCnALfBd#z#X|Cr#VJv#^^VZ\\Xb#Vj#fAdDj#|APz#Bj#Cn#Mz#Wr#[r#Ol#CZ?b#Hv#Nz#Ph#N`#XXb#XdDxAvBfAj#\\~#z#RTf#t#lAhDv#lBd#fAl#dAbA~AfAbCfA|Cr#zBf#dCZpADd#Dh#Bz#SnBk#zCOx#OhAWtDIxAGf#q#zBo#jBWvAC\\?j#H`Ad#fDBj#Ed#]~#iAzBiAnBuAhCARQd#_#rAkBdHu#xB]`#y#b#gAn#qA~#_#^a#d#Yr#g#bCOlAA`#B\\H\\Xx#Rv#Jv#LpBHvB#lBAfEEzAGtCCpCBv#Df#ZbAvAvDt#zBRbANrADrB?rAI|FIlA]rB_#hBUrA?TETEXAX#RNZ\\XTR^Jz#FhADf#Fl#Nh#RtA`ATVL^B\\E^sArGMr#?\\F^R^TPz#j#^Vc#\\qAx#"
},
"summary" : "B263 and කෝට්ටේ - බෝපේ පාර/B240",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}
Whats the difference when comparing both URL's, i can't seem to find any. Please help!
I'm trying to draw the routes between both origin and destination through a waypoint. How can I achieve this ??
Thank you!
Check your destination Latlng . The first link you are asking navigation from Sri Lanka to Nigeria(6.053518500000001,6.05351850000000). I think you are adding mismatch destination , ie, You are using the same latitude value for longitude also. Check your code.

How to get a picture of some location using GeoDataApi?

I wanted to know how to get the picture of some location using GeoDataApi instead of any of the newest Google Play services releases like 11.2.0 , say for example with 'com.google.android.gms:play-services:10.2.0' , how do i get a photo of a place? .
You can use Google Places Api to get the nearby places and the json or xml which you will get from here , for eg :
JSON
{
"html_attributions" : [],
"results" : [
{
"geometry" : {
"location" : {
"lat" : -33.870775,
"lng" : 151.199025
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/travel_agent-71.png",
"id" : "21a0b251c9b8392186142c798263e289fe45b4aa",
"name" : "Rhythmboat Cruises",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 270,
"html_attributions" : [],
"photo_reference" : "CnRnAAAAF-LjFR1ZV93eawe1cU_3QNMCNmaGkowY7CnOf-kcNmPhNnPEG9W979jOuJJ1sGr75rhD5hqKzjD8vbMbSsRnq_Ni3ZIGfY6hKWmsOf3qHKJInkm4h55lzvLAXJVc-Rr4kI9O1tmIblblUpg2oqoq8RIQRMQJhFsTr5s9haxQ07EQHxoUO0ICubVFGYfJiMUPor1GnIWb5i8",
"width" : 519
}
],
"place_id" : "ChIJyWEHuEmuEmsRm9hTkapTCrk",
"scope" : "GOOGLE",
"alt_ids" : [
{
"place_id" : "D9iJyWEHuEmuEmsRm9hTkapTCrk",
"scope" : "APP"
}
],
"reference" : "CoQBdQAAAFSiijw5-cAV68xdf2O18pKIZ0seJh03u9h9wk_lEdG-cP1dWvp_QGS4SNCBMk_fB06YRsfMrNkINtPez22p5lRIlj5ty_HmcNwcl6GZXbD2RdXsVfLYlQwnZQcnu7ihkjZp_2gk1-fWXql3GQ8-1BEGwgCxG-eaSnIJIBPuIpihEhAY1WYdxPvOWsPnb2-nGb6QGhTipN0lgaLpQTnkcMeAIEvCsSa0Ww",
"types" : [ "travel_agency", "restaurant", "food", "establishment" ],
"vicinity" : "Pyrmont Bay Wharf Darling Dr, Sydney"
},
{
"geometry" : {
"location" : {
"lat" : -33.866891,
"lng" : 151.200814
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "45a27fd8d56c56dc62afc9b49e1d850440d5c403",
"name" : "Private Charter Sydney Habour Cruise",
"photos" : [
{
"height" : 426,
"html_attributions" : [],
"photo_reference" : "CnRnAAAAL3n0Zu3U6fseyPl8URGKD49aGB2Wka7CKDZfamoGX2ZTLMBYgTUshjr-MXc0_O2BbvlUAZWtQTBHUVZ-5Sxb1-P-VX2Fx0sZF87q-9vUt19VDwQQmAX_mjQe7UWmU5lJGCOXSgxp2fu1b5VR_PF31RIQTKZLfqm8TA1eynnN4M1XShoU8adzJCcOWK0er14h8SqOIDZctvU",
"width" : 640
}
],
"place_id" : "ChIJqwS6fjiuEmsRJAMiOY9MSms",
"scope" : "GOOGLE",
"reference" : "CpQBhgAAAFN27qR_t5oSDKPUzjQIeQa3lrRpFTm5alW3ZYbMFm8k10ETbISfK9S1nwcJVfrP-bjra7NSPuhaRulxoonSPQklDyB-xGvcJncq6qDXIUQ3hlI-bx4AxYckAOX74LkupHq7bcaREgrSBE-U6GbA1C3U7I-HnweO4IPtztSEcgW09y03v1hgHzL8xSDElmkQtRIQzLbyBfj3e0FhJzABXjM2QBoUE2EnL-DzWrzpgmMEulUBLGrtu2Y",
"types" : [ "restaurant", "food", "establishment" ],
"vicinity" : "Australia"
},
{
"geometry" : {
"location" : {
"lat" : -33.870943,
"lng" : 151.190311
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "30bee58f819b6c47bd24151802f25ecf11df8943",
"name" : "Bucks Party Cruise",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 600,
"html_attributions" : [],
"photo_reference" : "CnRnAAAA48AX5MsHIMiuipON_Lgh97hPiYDFkxx_vnaZQMOcvcQwYN92o33t5RwjRpOue5R47AjfMltntoz71hto40zqo7vFyxhDuuqhAChKGRQ5mdO5jv5CKWlzi182PICiOb37PiBtiFt7lSLe1SedoyrD-xIQD8xqSOaejWejYHCN4Ye2XBoUT3q2IXJQpMkmffJiBNftv8QSwF4",
"width" : 800
}
],
"place_id" : "ChIJLfySpTOuEmsRsc_JfJtljdc",
"scope" : "GOOGLE",
"reference" : "CoQBdQAAANQSThnTekt-UokiTiX3oUFT6YDfdQJIG0ljlQnkLfWefcKmjxax0xmUpWjmpWdOsScl9zSyBNImmrTO9AE9DnWTdQ2hY7n-OOU4UgCfX7U0TE1Vf7jyODRISbK-u86TBJij0b2i7oUWq2bGr0cQSj8CV97U5q8SJR3AFDYi3ogqEhCMXjNLR1k8fiXTkG2BxGJmGhTqwE8C4grdjvJ0w5UsAVoOH7v8HQ",
"types" : [ "restaurant", "food", "establishment" ],
"vicinity" : "37 Bank St, Pyrmont"
},
{
"geometry" : {
"location" : {
"lat" : -33.867591,
"lng" : 151.201196
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/travel_agent-71.png",
"id" : "a97f9fb468bcd26b68a23072a55af82d4b325e0d",
"name" : "Australian Cruise Group",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 242,
"html_attributions" : [],
"photo_reference" : "CnRnAAAABjeoPQ7NUU3pDitV4Vs0BgP1FLhf_iCgStUZUr4ZuNqQnc5k43jbvjKC2hTGM8SrmdJYyOyxRO3D2yutoJwVC4Vp_dzckkjG35L6LfMm5sjrOr6uyOtr2PNCp1xQylx6vhdcpW8yZjBZCvVsjNajLBIQ-z4ttAMIc8EjEZV7LsoFgRoU6OrqxvKCnkJGb9F16W57iIV4LuM",
"width" : 200
}
],
"place_id" : "ChIJrTLr-GyuEmsRBfy61i59si0",
"scope" : "GOOGLE",
"reference" : "CoQBeQAAAFvf12y8veSQMdIMmAXQmus1zqkgKQ-O2KEX0Kr47rIRTy6HNsyosVl0CjvEBulIu_cujrSOgICdcxNioFDHtAxXBhqeR-8xXtm52Bp0lVwnO3LzLFY3jeo8WrsyIwNE1kQlGuWA4xklpOknHJuRXSQJVheRlYijOHSgsBQ35mOcEhC5IpbpqCMe82yR136087wZGhSziPEbooYkHLn9e5njOTuBprcfVw",
"types" : [ "travel_agency", "restaurant", "food", "establishment" ],
"vicinity" : "32 The Promenade, King Street Wharf 5, Sydney"
}
],
"status" : "OK"
}
The above JSON gives you the photo_reference which can be used in the Google PLaces Photos API to get a URL, which can be used to load the photos using Glide or Picasso as per the requirement.
This might help:
Google API documentation to use GeoDataApi
https://developers.google.com/android/reference/com/google/android/gms/location/places/GeoDataApi
Also, below is a reference link:
https://developers.google.com/places/web-service/photos#photo_references
Use the Google Place Photos api: https://developers.google.com/places/android-api/photos?hl=en

Json parsing to get lat long

I have a response from a google web service like the follwing
{
"html_attributions" : [],
"next_page_token" : "CpQCBgEAALxtLOBsfDviXsb8WHg4nGHrCETBydo0YcgOw-IHvFS4CQI1ZaM331dtA8Y3CxPeZZlF0IYjwQMp2A8W5A5UKtTrR4sQq1Um6FJgUNCpZzrcT6RwaPJKzOjbaFrPt5GqnQM6W1vxxdK9nKu5lyBbvLr0yJnzBWEAqyLyT2MFvak-_qDIR8b3yK3Efy34SsoHNnBnaANVc5hMztz7aWGphkTDNtEfuSZnQQ72jPg5_ey5F2G29in_QJXJlR9a3YYNGFmefLta2e0T34OGOhtvCinrdE7dcEUuaK55LV8TnP33HlGKC7PruXkv4AF8Xvxnlsk9ALVFdzECmJ4br6RTq3iWjBZ0z5FPNzqjfa6NNFiqEhDItZbJiBr9cEOaefilqJQSGhSybiB6SRFA8b-p86rFbiNEHjEo3w",
"results" : [
{
"geometry" : {
"location" : {
"lat" : 47.610399,
"lng" : -122.335791
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "8f7e7d038dbd13f283d1875ecf68d04fc2255561",
"name" : "GNC",
"opening_hours" : {
"open_now" : false
},
"place_id" : "ChIJ3zJ_hLRqkFQR0AxDtprgAjI",
"price_level" : 2,
"reference" : "CnRlAAAAoWRGwTPL4nLYI7qPZ2ukmXEdDWAScl5XASmeogPbQsOEvbFdXvb2cMYWsQZ1LR3QUYDo8djSpfKQc0BFLkA37iw_iTW2XRZy4568H5kReNd1xqVDjZyVmHPaWnKkJrTl0bJh_1P1Vpg-ntqUq-zVkRIQDVbTyrun8WsRA1eftayO8RoUSwjCBqkVaPwmyLJtXfJfk9qmF2I",
"scope" : "GOOGLE",
"types" : [ "health", "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "421 Pike St, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.61,
"lng" : -122.33
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "82e45a03dca8dcb2192cc250777a11f2e06452de",
"name" : "Deluxe Foods LLC",
"place_id" : "ChIJ9dKBxbVqkFQRoDLJeSe0CZo",
"reference" : "CoQBcwAAAD1dI5pifx1zH03cyQyPsJL10GZc7UFMHEKgZVzmIbZ77ZUdoXAme2iE3WzBgcCUuwg3zv735Pey9MrLWXdbKBmBGl_mvs_dD6aMmNYEhwft54gVpabn0ZVNLrflNEyun-dUkoeHvx5GEWNj1UvYGB1zbCY1CSUwbiqH4Ouay9GpEhBHwGUT7yCYw9IC3hGGUUxgGhRHU_AjT-jsRrHxoC6o7YKVpCLyCg",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "PO Box 30102, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.607573,
"lng" : -122.333167
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "695bf0d73be3b5f55ca43fe14abce48f9853ef15",
"name" : "Community Grocery",
"opening_hours" : {
"open_now" : false
},
"place_id" : "ChIJNeh4UrFqkFQRV3OXAHsHZxg",
"reference" : "CoQBcwAAALpG-2YSWEiceu-5h5km-SYuQelZR70nMSMg9uhs38uPusDF4s_5hnf6eQ8ORGJf7JGv9w9il4cL9to8r0bcA7HxK2ghxkrWlBbcP2asPWJTCdzrQB-uUs9TKxHc-kldayis9zmLQtHoDW_J8sSXlZHnHNYPol9VjKZIUiIlpYTNEhD9a-VcIRldCMVZhHNow03fGhRsw5lDMDZOcVEHdRBz2NAuhTdZ3Q",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "415 Seneca St, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.608163,
"lng" : -122.335371
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/wine-71.png",
"id" : "fde562e2d1e74e8ea18d3f758a05fe78c45d9346",
"name" : "Essential Market",
"opening_hours" : {
"open_now" : false
},
"place_id" : "ChIJvYQm8LNqkFQRjJM6WIcYE1A",
"rating" : 3.8,
"reference" : "CoQBcgAAALd33oAy_-Vxbcbf_gMywCqPHjyZixFi-yc1glcFFxbtpTDywxT-vPFKNExST7K305Ohv0AkhA_Br2Eh8AeetN-D7PxuW3mK5vsYPUbIfOTRWoM_CX2YH84cXOj9eFwGXwTiuXEOvOjhz8SYj59N4g78IUUDi-mfmGzd_C_jq90REhDJ3y45nfvr6IbfvapMnK0ZGhQDCjyU7Zu8ymTuQLGmoEsJRTVVGQ",
"scope" : "GOOGLE",
"types" : [
"liquor_store",
"grocery_or_supermarket",
"food",
"store",
"establishment"
],
"vicinity" : "1301 4th Ave, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.612122,
"lng" : -122.332044
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "6b4f8dc7039510bbbfca8fd12b359d444eef2be9",
"name" : "Clay's Market",
"place_id" : "ChIJdxjOE7VqkFQR4oDXOXnQEQ8",
"reference" : "CnRvAAAACC-kzX3pJo0x3OjptaM_wqWs5kbrk53V4xa6gYiOj3PP8Fo8L_DqSTjKRMqrF8bRGVfnTKtaLujZLvxkIgj7pNjyTAauRPKv0TL7dHpru66CyaJRNjoRSHME0xYHJJNj7VQDeLl5HO8dab0FZFrevxIQ6tZzbeqqRp6QEPf_Ue7XhBoU4Y3VkFBSCx_4b1pu1ApLYwXzLDQ",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "815 Pike St, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.609336,
"lng" : -122.337791
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "691548827b64fe2609fb7c27abbb1bcbe224f327",
"name" : "Kress IGA Supermarket",
"opening_hours" : {
"open_now" : false
},
"photos" : [
{
"height" : 600,
"html_attributions" : [],
"photo_reference" : "CnRnAAAAl-_QCXEqC8UaTUMrQDzG_bDcP56Lf2i2CPbBmxYj71VlemLiDrQpC38wmDTwsHvoFF_pGjLBo4vQHfPjM2nSLrPmHQeotYySYTwBhOcXPF9ISdvUNjBbyGUwCUFyBDvdcdIzaChOO0bEi5JVZRxNhRIQVsyOvUEat6gFROdcoh95HhoUS-Mac5cLzJFt12vSx_E7m_VUIfI",
"width" : 398
}
],
"place_id" : "ChIJbdIhoLNqkFQRMTiHCN6W4nU",
"rating" : 4.4,
"reference" : "CoQBdwAAAN3wdCAgdfatcILheBD3VwNP0Z_Zqjq8niNljnqpzHYJ2ieG6VEgxvfMQCU8BfawcRxO7MTu08gXtElThcYPdrQy5KFfAgdj1dFqi8PUh5R7wKKChjGN-sPj2cqRSIR-K853WjMlNMAhZSJMc2XWAhlbmy2AbXoe_9LsPoQfYE72EhCOBHIK_E0gTGPetycfRP6MGhSlBGpKKlZL00qldn6Xd44Y1TDj7A",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1427 3rd Ave, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.606546,
"lng" : -122.335449
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "3f23cf0c8bfdbe746a69d518c031dcafbd266d64",
"name" : "Netzel Associates",
"place_id" : "ChIJ1Q6vb7FqkFQR0PCOSJtLQpM",
"reference" : "CoQBdAAAABiMSr5ILBmkVjTeRpVAVHij7jMxhTacAJvz9YTFXVQYCP8he5wD4pAfaOu5dBlI4oagjaPPq8qUif9_hYN_IHTKpYnHaFWqCoHsHe-6kKIO1sIiE5qdLG-Buz2tQkVIPmzPqk67X60dgRux31vZjf10dg6BvizIiMTk5Q8D4AZWEhCJKbWcknUroTKKyatmH0JwGhS2i7O8iONEf9A5_qTBl3N1K8v4fg",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1111 3rd Ave # 2500, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.612607,
"lng" : -122.336984
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "1672b9dd46c6dcb5ae1409d0f87b23f1c38f33d0",
"name" : "Market Fresh Winter Garden",
"place_id" : "ChIJrdhDMksVkFQR0ugNKk-w7Fk",
"reference" : "CoQBfAAAAAxvLHmqlrTabI8g1bBkEMySU_pDqmYpmKmWNie37kRzknuKxRQkbPiVOs7cCB4yxiJGZ2X79qQW1dTFpJ9EE4jclrSKMFqzDqzPET1VHCR_imCSIWRLz_51iveURUW8r2GszBwCDISlu1iB1GBuLT58UB8Ghs-N3_yGxqaE_1JAEhBJn_a6kPPhJqGq9_pr4AifGhQNEEknt7JSyB1mvXCDgZ4o83aNng",
"scope" : "GOOGLE",
"types" : [
"meal_takeaway",
"restaurant",
"grocery_or_supermarket",
"food",
"store",
"establishment"
],
"vicinity" : "509 Olive Way, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.613069,
"lng" : -122.329411
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "08e8916d1ade44b3403b1a1268fc038bd449952b",
"name" : "Pike Grocery",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 384,
"html_attributions" : [],
"photo_reference" : "CnRnAAAAmx9YeUnwUAcOesWmlueyy2ZJQT-GLpRSd0_WXWHV0pP7c42-FvQYcfkpRoDPCHiqlzJSWa_fPcqADGvAi_HaLFCcUhcIbbrTeJOSvlP1bA_ACdWmPBDF26vYc6xAJqmtR37EXiZ5j-sVYh09_hpEzRIQap8C87zKuwIYfsR6zsAg2RoUsAbkV4FLlFmsKTthHEbVdd0G9VM",
"width" : 512
}
],
"place_id" : "ChIJMwdemspqkFQRUqQ91N-ufeo",
"reference" : "CnRvAAAAPclUek8vRV5Wcsbp4G08nttAphmKfTASUhTAR4I8vUnTFkSp7NP06JC4y3Xj7qTr9I105d7HpVkQJhuH6HDyLzej-FM5yDc7LqNMmkrAN3CcmQezcd9MhSZkdXdTDKTsYaZV4GgWogi4lqFcUgfhDBIQd1M7Sq4-EWJ4Y6cNUJPKHBoUnHoVxfWyl3lK7imAxJkxGkKNH9k",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1011 Pike St, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.606521,
"lng" : -122.337704
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "110c00b34dc635662716772ab4a0e0f6deced28a",
"name" : "Young's Market",
"place_id" : "ChIJ44qIiLFqkFQRw1TsXz9H2kg",
"reference" : "CnRwAAAAxMdsj6FXUIP8S9c42j9nSu7XtMyNY612TS6njqubsoZLBJwpr6GmxsrRKREPttLtBSYWOmq4gP2ovwO2utvqtLpjHcWs2YCFhNKj4k8Sz7F_d3aoAzOwNKmIp88bPxMbPUJj9eKI5gvTxct9CfRe4BIQolTWxCAybHKlUTMnfVgNfhoUlO1jmn7wrjUBVBcnZYe5QubTl_w",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1210 1st Ave, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.608777,
"lng" : -122.33973
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "d2f9218e208a84da7c7a7e2980cebd3671a8f386",
"name" : "Double Dorjee",
"place_id" : "ChIJkX3s-LJqkFQRQRexqCN0jQY",
"reference" : "CnRvAAAAoRDVxZ8W_qmEWPmjxXulAz9lS562rRQgirkEIhgXesLoXNgcJsw2iQIymEUKRmvQwrAOuLYrOIa8t1yPQdYYAvEajqIxcZ0PWzMEUeaDuCKL37p_WGzKOJuHhv0ki_3Z10BOPwmCNvo5XiOfz7j1ABIQK9UdmY_KTIYTP8tnoG5T_RoULYEoZrNBYy8EULQD7LUGs_E7krU",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1501 Pike St, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.608248,
"lng" : -122.339523
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "efeff82fc657a72cf8a3079aabe0e27d0d91a6c5",
"name" : "Lina's Fruit & Produce",
"place_id" : "ChIJD22J-LJqkFQRxhEAGumCphs",
"reference" : "CoQBeAAAAFcDpYes7w9SDBBHP_bOYNQrM1CUQichslNR-hyXATeyWMptKnIEdS27q0HR5BLfQAzQvgP_yIM2ElDrfSjtSdTVgiJlWZuVhtsBRIdV4n8cthl6uihZJnmtevrBYRq7GEid2Bp_IZiLJ4K6nYIpsyKlJNpBBvcKASbEsn4TAtM-EhCYsE2fgYPwEgX4ZHAkU6t7GhS2-N0cGpHzmVMAgNMKYP2GCW23-g",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1431 1st Ave # 7, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.605109,
"lng" : -122.333955
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "d81b188da1c901ec10149c5224e6fd1beac9ef9c",
"name" : "Second Avenue Sundries",
"place_id" : "ChIJexG9_rBqkFQRi7Zb8KM4P98",
"reference" : "CoQBeQAAAOH07x4jtyj3WTa6sWNSHXCPGItPL7kbSJbQFreF2VUJ-vxjenChmIoGcvsIREYEsV_dZYyXG3RoMpezUCUkuIvLsaEt1wxJcK6t0tM8QHylTdcc9IJRmjE_npy9rTbIehBixa5ESV1EGmF_rhyHQJyhPjAz7hmDcdlysEBRuySsEhAq3UlVuENA0aC8L59q8ZEFGhSUrFU9dmUkkl24SQ6RMQvA74mB5w",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "999 3rd Ave, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.614062,
"lng" : -122.335451
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "69ff94699431b37223bdea4fd7792c7244a6b36c",
"name" : "Sphere Foods",
"place_id" : "ChIJ1ef53EoVkFQRlYzOwPY7DhA",
"reference" : "CnRuAAAA6qjCWZS9h_Eb5x5UOAN2J99LIsJ9NEVR-LtbjUoLKx5OJmLmGGYEazQmbf02Rp8TrqyEVeE41rHimDGdvnQkj5WbLrxQCVM195Y3bLssymy7kUTFVaiclgZjVdEPf5WLcC9Xl6JjfiWxqN-5I1oEihIQZtGMYRH317G1c7rRQWd9MxoUmSFfTX5FwgECzfDH7hRFX4F5mJA",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1700 7th Ave # 2100, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.614425,
"lng" : -122.334307
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "e5be7cde6eb52cb0a5a7aa975ea915e2f80bd7dc",
"name" : "Stewart Street Market",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 1152,
"html_attributions" : [],
"photo_reference" : "CnRnAAAAqeZQn6gaLGIJib2WaNAcw7GdNLJuCc6AvrMCF543GBpl9tgLJ99CS0DmrdbHyWVMcw_H7q_LZgOqqKLwkilB95SjXsJqu4O3KMVQQAqtQWHW27u2vKVkTOqxAWTDppdManOPMUlFP2LLN1zya33z2xIQY-si5NTVqW9CpTd2AhP9NxoURwp9wSSgmZY2dtC1q6OezNsUvQw",
"width" : 2048
}
],
"place_id" : "ChIJ7yBfx0oVkFQRcLjVXNF_3qg",
"reference" : "CoQBeAAAADTkEpb503o9qN93lxGtIlh8x-uyIgRIs0Pj_-gGXpxQoQkAnIGcmVYgDLEzcFtpgzDchjxRWmns1RPUhqnThNJp4_VmG3ZP42zFNDAO_Q2_YowPiM7Wgz3oQsr66uIEBKZnNW9QRrd_GMbA64OdLZGrn7wZwvdp5UWCCnJJe0NFEhBKdwGNlHZTu2Y4BOi6Zl-lGhSbbDS4npeTaLx_cwgpmTmKUpp43g",
"scope" : "GOOGLE",
"types" : [
"convenience_store",
"grocery_or_supermarket",
"food",
"store",
"establishment"
],
"vicinity" : "1812 8th Ave, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.609322,
"lng" : -122.325655
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "87b467979468e6d2b5b203c7486d84e08505dd17",
"name" : "Plaza Select Foods",
"photos" : [
{
"height" : 720,
"html_attributions" : [ "From a Google User" ],
"photo_reference" : "CnRnAAAAhzdJBafPaRrh7mLSuB87bVza6ErJKRSvyNKU6pGa1EcblihzmqNx67HZQog-EO7wkvag7KP0bNXWvNXo9RF5u2vYNxZZ-5v7Z7KhL7tOmfWi7U7n6aFr9Sls_fZ_KcpBmH-m63Nl4H6E5GDFZwwNuxIQJUHOGAtXDDa9YT62KVkEjhoUVenpQc8oBGHYJOwTPiJDxSf2aH8",
"width" : 960
}
],
"place_id" : "ChIJy1bFH7ZqkFQRXpKoZ2NFh2Y",
"reference" : "CoQBdAAAAJZ0WNOu_ProGJ7t62FbE2ADOx6sGGH0YIR1KNGRqiZ9scWKjBjMhUHb3VNKZzEuvFUIBPOjrfBtkbjpEUthCC8HHbe_hsuLCyp2FUi2AFDVgBWB49X4fPla0IcNoOECfEzwRskswcKgcNyob1wt_mB2nEEbQVFDr8W6vhRsl1EyEhBgAGQ9WXQzLHZzzRs84JEyGhRM0Rx5TiF0g11uFT5mg6v6uHr97g",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1024 Madison St, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.608802,
"lng" : -122.340552
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "14a2e0601f06734e7c8be82ed00d3806e3f9ecd4",
"name" : "Corner Produce",
"place_id" : "ChIJn9FR9rJqkFQR89xobVdunBE",
"reference" : "CnRwAAAAFad6cCCAww55VmSDqvH9XCZzHx5LoyFH2MHT5YkFM9NZNr7L3eKhd02_VnSEunZ3sMlCyvT37k-Tg6EZV4MuWVOZ2imbVrPX1OeRgJWS6OgXx-FHabcAj2W5jgRkCsHwEhjwTW0DNYNDX5GEn-a1HRIQNsCEN53Q1PC3NAHCTutgARoU-4Qq8ZOFJfF3Lyyc1Xf66FN8KQ0",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1500 Pike Pl, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.60884,
"lng" : -122.340616
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "2a7a890254bcb2b1ae409cbf78d4e741800f036f",
"name" : "Oriental Mart",
"photos" : [
{
"height" : 460,
"html_attributions" : [
"\u003ca href=\"https://plus.google.com/115115924044576716973\"\u003eMatt Good\u003c/a\u003e"
],
"photo_reference" : "CnRtAAAAYab-XNz1Tm-iiB1qfxZJiC-T--LI7Mr5haR62p-RlGTrAIAPk2lhWogWOTQcFjPIHCiM2aYN2Iu-qkqPVGsEGony955zdEo6T3oOUKgNvT5WZvw6w_WU3aNdyLNh0xh-wRi4TNi6T70jutWPs6qkrRIQbdKBlQ6Yk1ROLxYnfSYF0BoUn9chrbaMj73dJleIqEzjxmi-9nY",
"width" : 816
}
],
"place_id" : "ChIJt7FX9rJqkFQR-R2iORwxyXQ",
"reference" : "CnRvAAAA8b_D2XlfYEVl6Oi5uYGRdJILg6dW3oRrLu8Q9xd9EukH2omaTGNlupKgahjJREN5jiNKdj9FSmpR4F0Du2XMbW9xmMEpO6CmPEG8zbBHQVNBs2zHzU2_m0WFnLv21mdxfAd20GVX6f6cdZ2COkb_KhIQhh6kZ-vny430yF0EvmH7eBoUZ3TVjq_RHxXlY_jpaN1qk2Yc3UM",
"scope" : "GOOGLE",
"types" : [
"convenience_store",
"grocery_or_supermarket",
"food",
"store",
"establishment"
],
"vicinity" : "1506 Pike Pl #509, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.608918,
"lng" : -122.340729
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "301d23a6579067833036e39ef46357e1d8e5ba68",
"name" : "Frank's Quality Produce",
"place_id" : "ChIJpdHb8LJqkFQRo8X7RoXoz2U",
"reference" : "CoQBeQAAAKEBHFRM9OPUb4CWC5bC1HYamXOFc0lzWyWCX-4eyhtOOIEvcxHIsj4y1xkBiXTIsttPetJYNr5KKux3Y3q5ZF7SKutTqiRYbk0hESohet1_EdcnPU31_IBRLo9W-T_7wiDb3FnN24rYmz9J9Kz7pxhlyKyR2VLMuTLMALNLJC2YEhChDDy463zp0HRiZaAsFSG3GhTe1n0deejJDnxNB2AK4zOf1HGkMw",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1508 Pike Pl, Seattle"
},
{
"geometry" : {
"location" : {
"lat" : 47.609231,
"lng" : -122.340848
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "228c792a04f0d9c3b8086b9f857521945f87c975",
"name" : "Choice Produce",
"place_id" : "ChIJmbBY97JqkFQR4JkuKXVDT3A",
"reference" : "CnRwAAAAWE1aK6eOe-rdRjgs2HJZHB__viCdWu2u7Qx0chME1CgDnnOycW_dcim98Szb2bzUjTy12wGk9fGO42jpywL-Zevm_ilfqi6q7jvRQxSGvsybbZau_Tc_orGj41Gz8fWK1R6_YvAT1n0II9DPFca1lxIQviRIxzWL3GRqyK3dun_4zRoUrNDpGHpGZHKUngGPiBLLH46zOqI",
"scope" : "GOOGLE",
"types" : [ "grocery_or_supermarket", "food", "store", "establishment" ],
"vicinity" : "1514 Pike Pl, Seattle"
}
],
"status" : "OK"
}
I need to parse it and get the lat and long values
I have assigned it like this
JSONArray JA=new JSONArray(result);
JSONObject json= null;
Where result contains the web service response. How can I parse it and get the required values?
try this code.you will get lat and lng value:
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
results = jsonObj.getJSONArray("result");
// looping through All Contacts
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
JSONObject geo = c.getJSONObject("geomatrics");
JSONObject place = geo.getJSONObject("location");
String id = place.getString(lat);
String name = place.getString(lng);
}}}
FYI, the response JSON is an Object, not an Array.
Steps to get lat/lng values:
Get results JSON array from received JSON Object response
Iterate through all the sub JSON Objects, then first get geometry sub object.
From geometry sub object, get location object. From location object, parse and get lat/lng values.
Please don't ask for code as there are many JSON tutorials exist on web but you can use below methods for parsing:
getJSONObject()
getString()
getLong()
There are multiple locations in the JSON so you will need and ArrayList to store all of them.
I recomment using ArrayList<HashMap<String,Double>>
Assuming you have the result as a String object named as result:
ArrayList<HashMap<String, Double>> list = new ArrayList<HashMap<String,Double>>();
JSONObject jsonObj= new JSONObject(result);
JSONArray results = jsonObj.getJSONArray("results");
for(int i=0;i<results.length();i++){
JSONObject temp = results.getJSONObject(i).getJSONObject("geometry").getJSONObject("location");
Double lat = temp.getDouble("lat");
Double lng = temp.getDouble("lng");
HashMap map = new HashMap<String, Double>();
map.put("lat",lat);
map.put("lng",lng);
list.add(map);
}
now you can retrive any position by using
Double lat=list.get(4).get("lat");
Double lng=list.get(4).get("lng");
Hope it helps. cheers :)
Cast the response to JsonObject like this
JSONObject jsonObj = new JSONObject(result);// where result is the response you got
Get the result array like this
JSONArray results = jsonObj.getJSONArray("results"); // where results is the tag in resposne
Now you have the entire array in results
for loop the entire stuff
for(int i=0;i<results.length();i++)
{
JSONObject location = results.getJSONObject(i).getJSONObject("geometry").getJSONObject("location");;
String lat = location.optString("lat");
String lng = location.optString("lng");
}
If you need the lat and long inside an array, add those to an array.

Comments in Google Place

I saw in the official documentation of google places : https://developers.google.com/places/documentation/search
that the response gave from the server to search is :
"results" : [
{
"formatted_address" : "529 Kent Street, Sydney NSW, Australia",
"geometry" : {
"location" : {
"lat" : -33.8750460,
"lng" : 151.2052720
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id" : "827f1ac561d72ec25897df088199315f7cbbc8ed",
"name" : "Tetsuya's",
"rating" : 4.30,
"reference" : "CnRmAAAAmmm3dlSVT3E7rIvwQ0lHBA4sayvxWEc4nZaXSSjRtfKRGoYnfr3d5AvQGk4e0u3oOErXsIJwtd3Wck1Onyw6pCzr8swW4E7dZ6wP4dV6AsXPvodwdVyqHgyGE_K8DqSp5McW_nFcci_-1jXb5Phv-RIQTzv5BjIGS0ufgTslfC6dqBoU7tw8NKUDHg28bPJlL0vGVWVgbTg",
"types" : [ "restaurant", "food", "establishment" ]
}...
I would like to know if it is posible to reach info like comments,
basically to reach more info that those 8 variables.
Tx !
it is disponible en :
"results" : [
"reviews" : [
{
"aspects" : [
{
"rating" : 3,
"type" : "quality"
}
],
"author_name" : "Simon Bengtsson",
"author_url" : "https://plus.google.com/104675092887960962573",
"text" : "Just went inside to have a look at Google. Amazing.",
"time" : 1338440552869
},
{
"aspects" : [
{
"rating" : 3,
"type" : "quality"
}
],
"author_name" : "Felix Rauch Valenti",
"author_url" : "https://plus.google.com/103291556674373289857",
"text" : "Best place to work :-)",
"time" : 1338411244325
},
{
"aspects" : [
{
"rating" : 3,
"type" : "quality"
}
],
"author_name" : "Chris",
"text" : "Great place to work, always lots of free food!",
"time" : 1330467089039
}
],
"types" : [ "establishment" ],
"url" : "http://maps.google.com/maps/place?cid=10281119596374313554",
"vicinity" : "48 Pirrama Road, Pyrmont",
"website" : "http://www.google.com.au/"
},
Official page: https://developers.google.com/places/documentation/details

Categories

Resources