[英]OpenLayers3 not stopping pending tile requests
我正在使用OL3
ol.layer.Tile
和ol.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.