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
在请求选项中列出此选项似乎行不通。 这里的代码部分与此相对应 :
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]);
}
}
}
代码会定位并列出结果, 如果我包括一个半径, 但结果没有按距离以升序排列。 Google s docs 说如果使用等级By 选项, 半径也没有必要 。 我是不是漏掉了?