簡體   English   中英

Google Maps API:radarSeach,其地圖邊界在外部返回結果

[英]Google Maps API: radarSeach with map bounds returning results outside

我有以下代碼:

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(經度)不在西南和東北經度之內。

有人看過嗎?

如這里解釋

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

“用於搜索位置時用於使結果產生偏差的邊界(可選)。如果設置了邊界,則位置和半徑都將被忽略。結果將不限於這些邊界內的結果;但是,結果內的結果將排名更高。”

對我來說,以界限作為參數執行搜索沒有任何意義,並且響應的結果超出界限。 我認為我唯一能做的就是在顯示結果之前對結果數組進行迭代,並檢查每個項目是否在范圍之內。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM