qpowell/google_places

spot.website, spot.city....always nil?

Closed this issue · 21 comments

Hi,
sorry, I don't find any information.
all is working fine, but when ask for spot.website , url, city etc it is always nil.
I get one image, different types, address and the spot name.
Do I have to pay for this website, url .. info on Google places?

Thanks, Michael

Hi Michael, sorry for my late reply. Do you still have this problem? As far as I know you don't have to pay for the information Google provides in the Places API.

I am having something similar, but with SPOT STREET returning "nil" all the time.

@guizero @Michael1969 Is this related to (or the same as) #53?

My problem is I don't have enough prowess to handle the data received. For example,

@client.spots(-33.8670522, 151.1957362, types: ['restaurant'])

With that, how can I get a decent Array of hashes where I can have each array item with accessible property likespot.city

It looks like Google Places search itself is no longer returning a bunch of this data: city, website, address components, etc?

https://developers.google.com/places/webservice/search#PlaceSearchRequests

But this available from an individual place lookup:
https://developers.google.com/places/webservice/details

@bl4ckdu5t - @amp343 is right. It doesn't look like this data is being returned anymore when you search spots. You can try something like the code below to get more detailed info for each spot:

spots = @client.spots(-33.8670522, 151.1957362, types: ['restaurant'])
@detailed_spots = spots.map { |spot| @client.spot(spot[:reference]) }

test_spot = @detailed_spots.first
test_spot.city # => "Sydney"
test_spot.formatted_address # => "529 Kent Street, Sydney NSW 2000, Australia"

You end up having to make an extra call for each spot you want the additional information on, but it will give you the data you need.

Hey @qpowell, thanks for finding that out. Do you think this is something the gem should handle?

@marceldegraaf I think that if this data used to be returned by the gem but is no longer there due to a change in the API, adding it back would probably be beneficial. I'm not sure if it would make more sense to do that in the current spots method as part of the options hash, or to create a new method for it.

In any case, I think part of the confusion lies in the documentation. This line in particular: "Each of the API methods below returns a GooglePlaces::Spot or a collection of those. Each of these objects has these attributes:". The GooglePlaces::Spot returned by spots does technically have those attributes but they aren't being set any more.

Right, I see how that is confusing. I'll try to fix this in the coming days, both in the code and in documentation.

Will this issue be fixed @marceldegraaf ?
BTW Thanks @qpowell

@briandiaz No problem!
@marceldegraaf if you're busy and don't have time to implement this, I'd be willing to submit a pull request if you could share how you were planning on addressing this.

@qpowell im getting an
GooglePlaces::InvalidRequestError: GooglePlaces::InvalidRequestError

At this line

current_spots = spots.map { |spot| @client.spot(spot[:reference]) }

@briandiaz I can take a look. Can you show me the line of code where you're defining spots?

Hey @qpowell and @briandiaz, sorry for my absence here. I've been busy and haven't had the time to work on Google Places. It doesn't really help that I don't use the gem myself anymore.

@qpowell I'd definitely merge a PR with a fix for this. Also, I'm considering handing over the project to someone who actually uses it, and has more time to maintain it. Would you be interested in that?

@marceldegraaf Yeah, I'd be interested. I'll send you an email to discuss this outside of the thread.

@qpowell

@client = GooglePlaces::Client.new("KEY_HERE")
types = ['bar','bakery','cafe','food','grocery_or_supermarket','meal_delivery','meal_takeaway','night_club','restaurant']
#Santiago
spots = @client.spots(19.451883,-70.6936117, :types => types)
current_spots = spots.map { |spot| @client.spot(spot[:reference]) }

@briandiaz Are you still having this issue? I was unable to reproduce this in two environments. If you don't have billing information attached to your Google dev account, the Places API is limited to 1000 requests in a 24 hour period.

@qpowell and @briandiaz I just read the code base, should it be place_id instead of reference. I tried with place_id and it works fine. reference does not make it work.

Closing, as this should now be fixed with the detail: true option in the latest release.

Great.