Google-maps – Google Places API search by city again

google mapsgoogle-maps-api-3google-places-api

I want to search all cafe and restaurants in New York. Of course, I can use Text Search, as it recommended here – Google Places API Search for Keyword and City

But if I do a request like
https://maps.googleapis.com/maps/api/place/textsearch/json?query=cafe+New+York+food&sensor=false&key=MY_KEY

First element, which I got, is

"formatted_address" : "316 Victoria Avenue, Chatswood NSW, Australia",

really no way to filter data by city? This data exists in address, why no good way to filter by city, only via keywords?

Best Answer

You can add a location parameter to your query (requires also to specify the radius).

so your query would look like :

https://maps.googleapis.com/maps/api/place/textsearch/json?query=cafe+New+York+food&sensor=false&location=40.67,-73.94&radius=100&key=YOUR_KEY

see the full documentation here : https://developers.google.com/places/documentation/search#TextSearchRequests

Related Topic