I want to get all the restaurants near my location order by distance. I am using textsearch with google places api using this url : https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurants&location=32.16107,34.806618&radius=200&sensor=true&key=api_key. The results that I am getting are sparse with no order what so ever. I tried rankby=distance but accurding to the documentation (https://developers.google.com/places/documentation/) you can use it only with regular search,means that when using textsearch there is no such parameter option (I tried it anyway -> not working). I am using textsearch because regular search returns only "types" : [ "establishment" ]. How can I order by distance the textsearch of google place api ? I can't believe that google didn't create a way to do it...
You are correct, Places API Textsearch does not support the rankBy=distance
parameter. If you believe that this would be a useful feature, please submit a Places API Feature Request.
You can however obtain the result you are looking for by performing a Places API Search Request using the rankBy=distance
parameter and the keyword=restaurant
parameter:
The keyword
parameter is matched against all available fields, including but not limited to name, type, and address, as well as customer reviews and other third-party content.