How to get city sights images from Google Places API

styopdev picture styopdev · Apr 16, 2015 · Viewed 7.8k times · Source

I use Google Places Photos Api and I want to get sights images for selected city by placeid or city title.

I try 2 methods:

1. f.e. I send request (used London placeid)

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJdd4hrwug2EcRmSrV3Vo6llI&key=API_KEY

get location from response

"lat": 51.5073509
"lng": -0.1277583

next step is request to

https://maps.googleapis.com/maps/api/place/radarsearch/json?location=51.5073509,-0.1277583&radius=5000&types=park|church|cafe|food|bar|night_club|stadium|store&keyword=&key=API_KEY

response contain many objects with placeid, that i use for new request like first

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ1eu1vwgIdkgRwjsifpZERQc&key=API_KEY

response contain photo_reference object which is the part of my image source

https://maps.googleapis.com/maps/api/place/photo?photoreference=CoQBcwAAAMLCk4X_WMliqIfISe-mgxRadycuzApodVcaCrTMGP6wQXJaquATedXMkvnjuLAfTG9xzBYQfSNm3iXV07wxHr_X_WDhfjz_yQjmqCYlKwYwK5hH-nl9qi-4ZZqKKtFuphFEY8ka25GYN2sTNMdd0v99j7YCzpR-lHJnl0zA9QoPEhBA5CnCgElBAU7Z92VTShg2GhQUes4fTRKiJlW6rYKYEaNilauWaA&key=API_KEY&maxwidth=1200

result image

It's not the best photo of London...

2. Using textsearch with param query=sights+in+London

https://maps.googleapis.com/maps/api/place/textsearch/json?query=sights+in+London&key=API_KEY

This request return response which are contains photo_reference objects. finally request is

https://maps.googleapis.com/maps/api/place/photo?photoreference=CnRnAAAAlLsg47UJRPVLdM8_sUbeLSia70EJ_mTisVDfCDTVUYNXl-35BGqzRARtq-Lt1CNcBWy3sKigfBVuF0iCr9-xqp1khK2l5JV3806LKvZrHJCaONYW35UBxxIIwxvxV-df4I4hg6f_zgeeIkWXGSYQhhIQNGYJl0fvHb3HslymbhH1thoUdLhGe8rJVCnyl_y0xAagzkFWs-Y&key=API_KEY&maxwidth=1200

result image

How can i get images like these

Answer

spiv picture spiv · May 31, 2016

The Places API directly returns some photos for cities like London now. For example your query for London by Place ID:

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJdd4hrwug2EcRmSrV3Vo6llI&key=API_KEY

Includes this photo of the Place of Westminster that is also shown on Google Maps.