【问题标题】:Google Maps API: radarSeach with map bounds returning results outsideGoogle Maps API:radarSeach,带有地图边界,在外面返回结果
【发布时间】:2015-07-16 15:18:28
【问题描述】:

我有以下代码:

google.maps.event.addListener(map, 'idle', function() {
    var request = {
        bounds: map.getBounds(),
        keyword: selected_provider //some value
    };

    service.radarSearch(request, function(results, status) {

        for (var i = 0; i < results.length; i++) {
            var marker = new google.maps.Marker({
                position: results[i].geometry.location,
                map: map
            });
        });

    });

});

在某些情况下,结果数组的某些位置会在地图边界之外打印标记。

map.getBounds() 返回:

oh {Da: mh, va: hh}
Da: A: -23.53883129305287 j: -23.53223111409202
va: A: -46.6811610542145 j: -46.686782964309714

某个结果:

A: -23.536062
F: -46.68732699999998

因此,F(经度)不在西南和东北的经度范围内。

有人见过吗?

【问题讨论】:

    标签: javascript google-maps-api-3


    【解决方案1】:

    这里解释

    https://code.google.com/p/gmaps-api-issues/issues/detail?id=8340

    “在搜索 Places 时,边界用于偏向结果(可选)。如果设置了边界,则位置和半径都将被忽略。结果将不限于这些边界内的结果;但是,其中的结果排名更高。”

    使用边界作为参数执行搜索对我来说没有任何意义,并且响应带有边界之外的结果。我认为我唯一能做的就是在显示结果数组之前对其进行迭代,并检查每个项目是否在边界内。

    【讨论】:

      猜你喜欢
      • 2013-07-12
      • 2017-04-16
      • 2015-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-24
      相关资源
      最近更新 更多