I'm using OL3
ol.layer.Tile
with ol.source.XYZ
to load tiles from a specific tile server.
Panning and zooming the map I noticed that the old pending tile requests (for example, the ones made to load a previous zoom level) are not automatically aborted, they keep going until they get a response. This doesn't happen with Leaflet.
Is it a bug? What should I do in order to get pending tile requests aborted by OL3
?
I'm interested in an answer too.
In the meantime with just ol3 one solution is to manually handle the tiles through a load function (I like to use promises, but easy to rewrite the below without one), set a timeout, and proceed. The code below is a bit overdone for just the purpose of a timeout but useful if one wants to manipulate the tiles before presented on the map.
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;
});
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.