Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places API Details request not returning photos array

As stated in the documentation, a "details" request should return a "photos" array, with photo references I should use to get up to 10 place photos.

Why am I not getting the photos array in the result? I have tried with various places.

This is the request url (details of New York):

https://maps.googleapis.com/maps/api/place/details/json?sensor=false&key=MY_API_KEY&reference=CkQzAAAAPElvIu2p9kjSSszAkpyP75LJ_AJUcKDZAifsRJw7_RFnSQ0cR2fjfa7MxQsvU0ct-fjUu6H7r7j4torvd0p5YhIQxyAtJFyY_kUH03Yomxt67BoUQDFZd2WonLfujVVzlUEm5V5Eh4Q

And this is the result:

    {
   "debug_info" : [],
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "New York",
            "short_name" : "New York",
            "types" : [ "locality", "political" ]
         },
         {
            "long_name" : "New York",
            "short_name" : "NY",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "United States",
            "short_name" : "US",
            "types" : [ "country", "political" ]
         }
      ],
      "adr_address" : "\u003cspan class=\"locality\"\u003eNew York\u003c/span\u003e, \u003cspan class=\"region\"\u003eNY\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUSA\u003c/span\u003e",
      "formatted_address" : "New York, NY, USA",
      "geometry" : {
         "location" : {
            "lat" : 40.7143528,
            "lng" : -74.00597309999999
         },
         "viewport" : {
            "northeast" : {
               "lat" : 40.9152555,
               "lng" : -73.700272
            },
            "southwest" : {
               "lat" : 40.496006,
               "lng" : -74.25573489999999
            }
         }
      },
      "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
      "id" : "7eae6a016a9c6f58e2044573fb8f14227b6e1f96",
      "name" : "New York",
      "reference" : "CoQBdAAAAPo9DMqO2AGw5LN5rohSnnCMGPCv3Lff6tR7HUbe00ka-_Unq4blHt3zkn_tyCvnRRuLBv9-S0FGghJwtXe2veG5fQKAa_2GVm38L5RucayjBDURlLcOF986c9rmk0nlppCgc5QL9zgPBnKV_ZT01mdTu8n7m7ceOY3BSaII41bKEhCW5Ldw4ioRZp_EChzdtZazGhRRYOblvpy3eEc9OjE0QDD3e3sXyw",
      "types" : [ "locality", "political" ],
      "url" : "https://maps.google.com/maps/place?q=New+York,+NY,+USA&ftid=0x89c24fa5d33f083b:0xc80b8f06e177fe62",
      "vicinity" : "New York"
   },
   "status" : "OK"
}
like image 352
syonip Avatar asked Nov 01 '22 08:11

syonip


1 Answers

I ran into this same issue. I found that it's to do with how you're retrieving the reference ID. I was doing a text search on address only, and when I pulled details on the resulting reference ID, there were no photos or reviews.

However, I then did another text search off the name of the place (along with address) and you get back a different reference ID. Pulling details on this contains the missing elements.

Even though both locations pointed to the same address, they were in fact different reference IDs.

like image 74
Shane Bammel Avatar answered Nov 08 '22 14:11

Shane Bammel