Reputation: 31
I'm using Google Places API to get nearby restaurants, but I've noticed that the results don't include the website address(URL) and exact photo URL.Here is the sample result I searched for resturants near Austrailia, the image shows sample response of "The Star" restaurant
If we get the same place "The Star" via google places autocomplete then it do return website URL(http://www.star.com.au/) and photo URL too. Is there a way to get the website address(URL) and photo included in the results?
This is the call I'm using:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=<lat,lng>&radius=500&type=restaurant&key=<api_key>
Any help will be appreciated
Upvotes: 1
Views: 4773
Reputation: 2518
This is because place search results contain less detail than place detail results.
As the Search Results documentation for photos[]
says:
A Place Search will return at most one photo object. Performing a Place Details request on the place may return up to ten photos.
Similarly, there's no website
field on search results (and so it is not listed on that documentation page).
You need to make a Place Details request to get those details:
A Place Details request returns more comprehensive information about the indicated place
And sure enough, there's a website
field in the Place Details Results documentation:
website
lists the authoritative website for this place, such as a business' homepage.
And that's exactly what I see for the "The Star" in Sydney. In search results I see 1 photo (just like you see in your screenshot), and no website URL. Then in the details response for that result I get 10 photos, and the website.
Upvotes: 4