Google-maps – Google Maps search box vs Google Places API

google mapsgoogle-places-api

I'm quite new to the Google Places API. What I want to achieve is create a simple search box where people can search places based on Google places, and choose one of them to get the coordinate (latitude, longitude).

Currently I'm using the Google Places API. All the steps are pretty straight forward, but after using it for a couple of day, I realize that sometimes the result from the Google Maps search box is better than the Google places API.

Below is what I test right now for Google Maps and the Google Places API

  • I test the result from the Google Maps search box with maps.google.com and see all the autocomplete.
  • I'm using the Google places API without any limitation in radius (orderby=distance), sensor is false, I put the user current location in the location parameters and the text into the keyword field.

Based on this configuration, the results are different. May I know if someone knows and would be willing to share how to configure the Google Places API URL to get the same results as with the Google Maps search box?

Or is it unachievable? That is, will the Google Places API search result not be as good as when we search in Google Maps? If so, is there any policy that does not allow people to only use the Google search box and the coordinate result without showing the map?

Best Answer

I believe Google Maps autocomplete uses a combination of results from the Place autocomplete and Query autocomplete services. Based on your mention of rankby=distance, it sounds like you're using the nearbysearch service, which will return somewhat different results from the autocomplete services. Have a look at the Google Places API documentation for the details of using the autocomplete services.

https://developers.google.com/places/documentation/