小编JFl*_*Flo的帖子

google maps api v3如何按最近距离排名

有谁知道如何使用这里提到的距离搜索选项的排名? 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]);
        }
    } 
}
Run Code Online (Sandbox Code Playgroud)

如果我包含半径,代码将定位并列出结果,但结果不按距离的升序列出.谷歌的文档说,如果使用rankBy选项,则不需要半径.我错过了什么吗?

search google-maps rank

8
推荐指数
2
解决办法
2万
查看次数

标签 统计

google-maps ×1

rank ×1

search ×1