javascript - Google Places API library is not returning photo_reference attribute -


i'm using google places api details of place, it's not returning photo_reference attributes photos. why??

here's how i'm calling it:

  var request = {     placeid: 'chijn1t_tdeuemsrusoyg83fry4'   };    service = new google.maps.places.placesservice(document.createelement('div'));   service.getdetails(request, callback);    function callback(placed, status) {     console.log( placed );     console.log( json.stringify(placed) );     if (status == google.maps.places.placesservicestatus.ok) {       console.log( placed );     }   } 

and here's response

{    "address_components":[       {          "long_name":"5",          "short_name":"5",          "types":[             "floor"          ]       },       {          "long_name":"48",          "short_name":"48",          "types":[             "street_number"          ]       },       {          "long_name":"pirrama road",          "short_name":"pirrama rd",          "types":[             "route"          ]       },       {          "long_name":"pyrmont",          "short_name":"pyrmont",          "types":[             "locality",             "political"          ]       },       {          "long_name":"council of city of sydney",          "short_name":"sydney",          "types":[             "administrative_area_level_2",             "political"          ]       },       {          "long_name":"new south wales",          "short_name":"nsw",          "types":[             "administrative_area_level_1",             "political"          ]       },       {          "long_name":"australia",          "short_name":"au",          "types":[             "country",             "political"          ]       },       {          "long_name":"2009",          "short_name":"2009",          "types":[             "postal_code"          ]       }    ],    "adr_address":"5, <span class=\"street-address\">48 pirrama rd</span>, <span class=\"locality\">pyrmont</span> <span class=\"region\">nsw</span> <span class=\"postal-code\">2009</span>, <span class=\"country-name\">australia</span>",    "formatted_address":"5, 48 pirrama rd, pyrmont nsw 2009, australia",    "formatted_phone_number":"(02) 9374 4000",    "geometry":{       "location":{          "lat":-33.8666113,          "lng":151.19583239999997       },       "viewport":{          "south":-33.8669293,          "west":151.19521829999996,          "north":-33.86650529999999,          "east":151.1960371       }    },    "icon":"https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",    "id":"4f89212bf76dde31f092cfc14d7506555d85b5c7",    "international_phone_number":"+61 2 9374 4000",    "name":"google",    "opening_hours":{       "open_now":false,       "periods":[          {             "close":{                "day":1,                "time":"1800",                "hours":18,                "minutes":0,                "nextdate":1468828800000             },             "open":{                "day":1,                "time":"0800",                "hours":8,                "minutes":0,                "nextdate":1468792800000             }          },          {             "close":{                "day":2,                "time":"1800",                "hours":18,                "minutes":0,                "nextdate":1468915200000             },             "open":{                "day":2,                "time":"0800",                "hours":8,                "minutes":0,                "nextdate":1468879200000             }          },          {             "close":{                "day":3,                "time":"1800",                "hours":18,                "minutes":0,                "nextdate":1469001600000             },             "open":{                "day":3,                "time":"0800",                "hours":8,                "minutes":0,                "nextdate":1468965600000             }          },          {             "close":{                "day":4,                "time":"1800",                "hours":18,                "minutes":0,                "nextdate":1469088000000             },             "open":{                "day":4,                "time":"0800",                "hours":8,                "minutes":0,                "nextdate":1469052000000             }          },          {             "close":{                "day":5,                "time":"1800",                "hours":18,                "minutes":0,                "nextdate":1469174400000             },             "open":{                "day":5,                "time":"0800",                "hours":8,                "minutes":0,                "nextdate":1469138400000             }          }       ],       "weekday_text":[          "monday: 8:00 – 6:00 pm",          "tuesday: 8:00 – 6:00 pm",          "wednesday: 8:00 – 6:00 pm",          "thursday: 8:00 – 6:00 pm",          "friday: 8:00 – 6:00 pm",          "saturday: closed",          "sunday: closed"       ]    },    "photos":[       {          "height":1365,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/105932078588305868215/photos\">maksym kozlenko</a>"          ],          "width":2048       },       {          "height":3120,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/116783625253584801301/photos\">samson jabin</a>"          ],          "width":4160       },       {          "height":1184,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/106645265231048995466/photos\">malik ahamed</a>"          ],          "width":1776       },       {          "height":960,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/100919424873665842845/photos\">donnie piercey</a>"          ],          "width":1280       },       {          "height":3024,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/117393076859685917096/photos\">joann chu</a>"          ],          "width":4032       },       {          "height":5582,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/110754641211532656340/photos\">robert koch</a>"          ],          "width":2866       },       {          "height":2988,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/103594026264127040754/photos\">daniel tyson</a>"          ],          "width":5312       },       {          "height":2448,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/116976377324210679577/photos\">wh chen</a>"          ],          "width":3264       },       {          "height":1184,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/106645265231048995466/photos\">malik ahamed</a>"          ],          "width":1776       },       {          "height":4160,          "html_attributions":[             "<a href=\"https://maps.google.com/maps/contrib/116783625253584801301/photos\">samson jabin</a>"          ],          "width":3120       }    ],    "place_id":"chijn1t_tdeuemsrusoyg83fry4",    "rating":4.6,    "reference":"cmraaaaaxa9pjme9u0gwglgbnp5nlj_r92tktn3ry9mx22rtshhzsnnyd3rvnvzl33pb_7qyhodzq_kkkx2kh9jib0nyxuungvz2uko_omakrvjgvnrj2y6ue78-ovbto6y5nde0ehbcqrgjqwr2h2rv2zwzrmpcght_f4zfk2oybor8uimeqgiwtbtfew",    "reviews":[       {          "aspects":[             {                "rating":3,                "type":"overall"             }          ],          "author_name":"nila sweeney",          "author_url":"https://plus.google.com/115167791509064907883",          "language":"en",          "profile_photo_url":"//lh4.googleusercontent.com/-p-5ldzmjbig/aaaaaaaaaai/aaaaaaaavay/df_n6xr0i2i/photo.jpg",          "rating":5,          "text":"amazing place!  incredibly vibrant , hip. love way office have been laid out. way work-life balance encouraged impressive!  google, please hire me! ",          "time":1464213084       },       {          "aspects":[             {                "rating":0,                "type":"overall"             }          ],          "author_name":"thehealthretreat",          "author_url":"https://plus.google.com/110246682709687277403",          "language":"en",          "rating":1,          "text":"i spend 250 thousand dollars year google adwords..\ni own mental health drug , alcohol retreat.\n\na fictitious person antony william posted negative review on business.\n\nthis person has never attended.  asked google last 8 weeks remove third party review, sent 20 times statutory declaration googlemybusiness goodle reviews , google legal stating mr antony had never attended program.\n\ngoogle have refused remove review though breaches googles own guidelines , post defamatory.\ngoogle enabling person continue hurt our business 100000 per month since post went up.\n\nmy request post removed being stone walled google.\n\ni cannot believe google treat business partners shabbily when being wronged anonymous person or believe competition business.\ngoogle says on , on negotiate antony william,  how can negotiate doesn't exist?  frustrating , plain wrong.\n\nif google client spends 250000 ausd year them, god all.\n\nby way if have depression , anxiety dealing google, come , you. regards francis",          "time":1468373176       },       {          "aspects":[             {                "rating":0,                "type":"overall"             }          ],          "author_name":"steve morgan",          "author_url":"https://plus.google.com/103384372688674733198",          "language":"en",          "profile_photo_url":"//lh5.googleusercontent.com/-xcubmlcbdas/aaaaaaaaaai/aaaaaaaaiae/olwrkcph3xs/photo.jpg",          "rating":1,          "text":"latest andriod update 5.0 has broken google  play samsung note  3. no gmail apo no fitbit exercise  logging.  absolutely  disgusting.  sebds ne apple",          "time":1468325696       },       {          "aspects":[             {                "rating":3,                "type":"overall"             }          ],          "author_name":"keith hong",          "author_url":"https://plus.google.com/106314339785578978358",          "language":"en",          "profile_photo_url":"//lh3.googleusercontent.com/-z69cmmxhr-c/aaaaaaaaaai/aaaaaaaaaes/cbphm5oqkas/photo.jpg",          "rating":5,          "text":"not invited google australia hq. neat spot. love pirrama place odi location pretty cool (and overtakin of fairfax) ",          "time":1464676368       },       {          "aspects":[             {                "rating":3,                "type":"overall"             }          ],          "author_name":"alejandro silva avila",          "author_url":"https://plus.google.com/102339092633102421576",          "language":"en",          "profile_photo_url":"//lh5.googleusercontent.com/-wrvjv4euhjy/aaaaaaaaaai/aaaaaaaausk/6ujjkzu6u9w/photo.jpg",          "rating":5,          "text":"completely stunning , different you'd imagine. many cool things see , you'd think people lost trying work haha! :)",          "time":1467896264       }    ],    "scope":"google",    "types":[       "point_of_interest",       "establishment"    ],    "url":"https://maps.google.com/?cid=10281119596374313554",    "utc_offset":600,    "vicinity":"5 48 pirrama road, pyrmont",    "website":"https://www.google.com.au/about/careers/locations/sydney/",    "html_attributions":[     ] } 

i can photo_reference attributes if use url see details of same place:

https://maps.googleapis.com/maps/api/place/details/json?reference=cmraaaaaxa9pjme9u0gwglgbnp5nlj_r92tktn3ry9mx22rtshhzsnnyd3rvnvzl33pb_7qyhodzq_kkkx2kh9jib0nyxuungvz2uko_omakrvjgvnrj2y6ue78-ovbto6y5nde0ehbcqrgjqwr2h2rv2zwzrmpcght_f4zfk2oybor8uimeqgiwtbtfew&sensor=false&key=aizasyamutqw6a8sqesv77boqhf3tvtsaajy09c 

when using javscript library, photo objects have method "geturl" instead of photo_reference. it's bit confusing, can loop on images , call method maxheight and/or maxwidth (at least 1 of them must present) , return photo url.

https://developers.google.com/maps/documentation/javascript/3.exp/reference#placephoto

function callback(placed, status) {     console.log( placed );     console.log( json.stringify(placed) );     if (status == google.maps.places.placesservicestatus.ok) {         placed.photos.foreach(photo => {             console.log(photo.geturl({maxheight: 300})) // log url no photo_reference         })     }     } 

unfortunately have not yet figured out how photo_reference javascript library.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -