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

Ishan picture Ishan · May 18, 2013 · Viewed 21.1k times · Source

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=

Answer

Alfred picture Alfred · Jun 21, 2013

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"