Dumb Hack to Get Google Places Reference Key
Okay, so this is pretty stupid, but I still for the life of me can’t figure out how to grab my Google Places Reference Key to use in the Google Places API. I read through everything but only found examples that were already using a reference key. So I opted to go for a stupid workaround that I knew would work.
The Places API spits out an object from a search with 10 different pieces of information, in the first level at least. So here’s the code I used:
To run you through what you should see, you’ll get a map to the left centered on the lat, long you set and based on the query that you set up as well (Line 37). With that you should get the results of several places that match your search. Open console and check out the Objects that are waiting for you. They should be laid out like this:
formatted_address: "2461 Coral Way, Miami, FL, United States" geometry: Object html_attributions: Array icon: "http://maps.gstatic.com/mapfiles/place_api/icons/dentist-71.png" id: "9558f3e8193cd81d69bd6e40eba5b2983b86fc56" name: "Dr. Ramon Bana, DDS" opening_hours: Object photos: Array rating: 4.7 reference: "CoQBdgAAAE1pNpBPXSsgpwCyvJ6qZxmw73SNRt4V1YSZqyfnqnaZWgG1_cjRvWu1TMsnnUIwozibby9M8jIJgMwsFi7iyTxyqXNWTa0aZMZBMC03BhnQx_VV-KP90AvuORf6F9NcocmC9ve1Tfk5jNY3sFZkcbTbG6_c5x5rXnWYwlTVVwzoEhCY7UCUkiqAh2IsKE92dzknGhSLcf-UBetR77CsLLpOikIjO0GEuQ" types: Array __proto__: Object
And looky there, there’s a reference just waiting for you. You can now use that reference to grab reviews etc. with the Place Details portion of the Places API. Again, there’s probably an easier way to do this, but sometimes I’m dumb and have to do it in a very dumb way. Enjoy!
For those of you that cringed when you saw eval() I’ve already been scolded about that, so save those comments or let me have it to really rub salt in the wound.