Difference between a nearby search and a text search in Google Places API

google-places-apisearch

Whats the difference between a nearby Search and a text Search in Google Places API?

For example, a nearby Search for cafe within a radius of 1km returns only 1 result using https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&types=cafe&key=your_api_key

while text Search for cafe within a radius of 1km returns 20 results using https://maps.googleapis.com/maps/api/place/textsearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&query=cafe&key=your_api_key.

Changing types to type in the nearby search also returns 20 results which are also different to the result found using the text search above. ie https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&type=cafe&key=your_api_key

When you do a search for cafe on google maps android app using the location given above, the result you get is the same as the result you get by using the text search above.

For convenience, the above clickable links are below.

https://maps.googleapis.com/maps/api/place/textsearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&query=cafe&key=

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&type=cafe&key=

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&types=cafe&key=

Best Answer

Simply put nearby places allows you to search more vaguely but only return specific results. In Text Search, if you search for "restaurants", it will search for locations, establishments or names with the text "restaurants".Anything that is related to restaurants. Meanwhile in nearby search, if you search for "restaurants", it will return restaurant establishments with or without the text "restaurants" but only establishments of "restaurants"

Related Topic