Only set LOADED state when all source tiles loaded successfully

This commit is contained in:
Andreas Hocevar
2017-09-11 22:40:12 +02:00
parent b65c6f7e8e
commit 8573a7ba64
2 changed files with 7 additions and 2 deletions

View File

@@ -263,17 +263,23 @@ ol.VectorImageTile.prototype.load = function() {
*/
ol.VectorImageTile.prototype.finishLoading_ = function() {
var loaded = this.tileKeys.length;
var empty = 0;
for (var i = loaded - 1; i >= 0; --i) {
var state = this.getTile(this.tileKeys[i]).getState();
if (state != ol.TileState.LOADED) {
--loaded;
}
if (state == ol.TileState.EMPTY) {
++empty;
}
}
if (loaded == this.tileKeys.length) {
this.loadListenerKeys_.forEach(ol.events.unlistenByKey);
this.loadListenerKeys_.length = 0;
this.setState(ol.TileState.LOADED);
} else {
this.setState(empty == this.tileKeys.length ? ol.TileState.EMPTY : ol.TileState.ERROR);
}
this.setState(loaded > 0 ? ol.TileState.LOADED : ol.TileState.ERROR);
};

View File

@@ -65,7 +65,6 @@ describe('ol.rendering.layer.VectorTile', function() {
source = new ol.source.VectorTile({
format: new ol.format.MVT(),
tileGrid: ol.tilegrid.createXYZ(),
tilePixelRatio: 16,
url: 'rendering/ol/data/tiles/mvt/{z}-{x}-{y}.vector.pbf'
});
});