google-mapsgoogle-places-apigoogle-places

Google Place Search does not return result


I need to fetch location data based on given text. As example if I search Aldi in google map it shows me lot of data with pagination. I need to get that result using google places api.

I tried it with two API calls. But it returns me following result

https://maps.googleapis.com/maps/api/place/textsearch/json?query=Aldi&key=MY_KEY

Result

{
   "html_attributions" : [],
   "results" : [],
   "status" : "ZERO_RESULTS"
}

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=ALDI&inputtype=textquery&fields=place_id,name,formatted_address,geometry&key=MY_KEY

Result

{
   "candidates" : [],
   "status" : "ZERO_RESULTS"
}

I need to fetch data based on the given name. Can anyone find out the reason.


Solution

  • You should be aware that Places API search is not designed to provide results world wide. In your examples you specify only text value 'Aldi'. However, in order to get results you should specify also where you are searching.

    For example, if I want to bias results towards Barcelona area in Spain I have to add location and radius in my request

    https://maps.googleapis.com/maps/api/place/textsearch/json?query=Aldi&location=41.3850639%2C2.1734035&radius=10000&key=MY_API_KEY

    This request will return Aldi supermarkets in Barcelona area as shown in my screenshot

    enter image description here

    The same thing for Find place, you should specify location bias

    https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Aldi&inputtype=textquery&fields=formatted_address,geometry,name,place_id&locationbias=circle%3A1000%4041.3850639%2C2.1734035&key=MY_API_KEY

    Also note that Find place returns only one result.

    I hope this addresses your doubt.