簡體   English   中英

OpenLayers3沒有停止掛起的磁貼請求

[英]OpenLayers3 not stopping pending tile requests

我正在使用OL3 ol.layer.Tileol.source.XYZ從特定的tile服務器加載tile。

平移和縮放地圖我注意到舊的待處理磁貼請求(例如,用於加載先前縮放級別的請求)不會自動中止,它們一直持續到它們得到響應。 Leaflet不會發生這種情況。

這是一個錯誤嗎? 為了讓OL3中止掛起的OL3貼請求,我該怎么做?

我也對答案很感興趣。

與此同時,只有ol3一個解決方案是通過加載函數手動處理切片(我喜歡使用promises,但很容易在沒有一個的情況下重寫下面的內容),設置超時,然后繼續。 下面的代碼有點過頭了,只是為了超時的目的,但是如果想要在地圖上顯示之前操作切片有用。

tileLoadFunction: offline.get_tile_function(layername),

function get_tile_function(layername) {
return function my_tileLoadFunction(it, s) {
    var ie = new Image();
    var clock;

    var p = new Promise (function (win, fail) {
        ie = it.getImage();

        clock = setTimeout(function() {
            return fail(Error('skipping tile, source for '+layername+' +
            +took too long to provide img data'));
        }, 3000); 

        getRemote();

        //all one has to do is win(s) the source (s)
        //but instead, get the image and do something with it...
        function getRemote() {
            //... like calling a canvas context pixel manipulation subroutine
            pixelManipulate(s).then(function(newpixeldata) {
                return win({image or image data})
            }, function (err) {
                return fail(Error('problem playing w/pixels'))
            })
        }
    })


    p.then(function(data) {
        if (clock) clearTimeout(clock)
        ie.src = data;
        ie = null;
    }, function(error) {
        if (error) console.log(error)
        ie.src = '';
        ie = null;
    });
}
})

暫無
暫無

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

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