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?