Google Places - Get Place Photos

Hello community,

Is anyone else struggling with pulling a place’s photo? I’ve been able to pull other place information (e.g., rating, phone number) but can not crack how to get an image to show…Before I go mad, just want to be sure there isn’t a problem/bug with this currently. Thanks!

1 Like

What you’re retrieving is a list of images, not just a single image. While it’s possible that a specific Google place result only has one image for that listing, the underlying data structure of the API call tells Bubble to expect a list.

Given that you’re using a single image element, Bubble is asking you to specify “which one” - the first one, the last one, some random one, etc.

Otherwise, if you wanted to display all of the images in a carrousel, you could either put the image element inside of a repeating group or install an image carousel plugin (and set the data source to not include an item # modifier, which would show the full list).


Dan (creator of LearnTo - 15+ hours of Bubble tutorials and live coaching)

3 Likes

Thanks a lot dan. Appreciate the time.

I guess the problem is that even if I choose last item, first item, random item - it doesn’t let me stop there and requests that I also add “width”, “height”, “photo reference” or “attribution”. I just want to display a single photo - beyond that not particular, but cannot figure it out.

This is the issue with using Plugins rather than looking at the API documentation itself.

What you are getting as part of the Places APi “Photos” is not an image, nor a list of images.

It is an array (usually of 1 for Place API) of image details. One of the attributes is the “Photo Reference”.

You then use that Photo Reference to call the Place Photos API which will return you the actual image.

See here …

https://developers.google.com/places/web-service/photos

You could do it all in the dynamic image editor if you wanted.

https://maps.googleapis.com/maps/api/place/photo?photoreference=do the places API call and return the first reference

3 Likes

Thank you, Nigel!

This topic was automatically closed after 14 days. New replies are no longer allowed.