Does anyone know how to use the rank by distance search option that is mentioned here?
https://developers.google.com/maps/documentation/javascript/places#place_search_requests
Listing this in the request options doesn’t seem to work. Here’s my portion of code relative to this:
var request = {
location: coords,
//radius: 30000,
keyword: ['puma, retail'],
types: ['store'],
rankBy: google.maps.places.RankBy.DISTANCE
};
service = new google.maps.places.PlacesService(map);
service.search(request, callback);
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
listResults(results[i]);
}
}
}
Code will locate and list results if I include a radius, but the results aren’t listed in ascending order by distance. Google’s docs say a radius isn’t necessary either if using the rankBy option. Am I missing something?
Was having the same problem.
As per this source: http://www.geocodezip.com/v3_GoogleEx_place-search.html
I was able to formulate the query as such:
Var key is API key which is not required but added for later use. GPS is:
Lastly, I did everything that you did except I added bounds to a map that I was not going to use. For that I did: