2016-06-30 7 views
3

私はOL3ol.layer.Tileol.source.XYZを使用して、特定のタイルサーバーからタイルをロードしています。OpenLayers3が保留中のタイルリクエストを停止しない

地図のパンとズーム古いペンディングタイルリクエスト(たとえば、以前のズームレベルをロードしたもの)が自動的に中止されないことに気がつきました。これはリーフレットでは起こりません。

バグですか?保留中のタイルリクエストをOL3で中止するにはどうすればよいですか?

答えて

1

私も答えに興味があります。

一方、ちょうどol3では、負荷機能(私は約束を使用するのが好きですが、以下のものを使わずに書き換えが簡単です)でタイルを手動で処理し、タイムアウトを設定して処理を進めます。以下のコードは、タイムアウトの目的のために少しオーバーしていますが、地図上に表示される前にタイルを操作したい場合に便利です。

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; 
    }); 
} 
}) 
関連する問題