diff --git a/src/ol/source/VectorTile.js b/src/ol/source/VectorTile.js index 497051b41e..0cebf7a11d 100644 --- a/src/ol/source/VectorTile.js +++ b/src/ol/source/VectorTile.js @@ -12,7 +12,6 @@ import {createXYZ, extentFromProjection, createForProjection} from '../tilegrid. import {buffer as bufferExtent, getIntersection, intersects} from '../extent.js'; import EventType from '../events/EventType.js'; import {loadFeaturesXhr} from '../featureloader.js'; -import {isEmpty} from '../obj.js'; import {equals} from '../array.js'; /** @@ -252,10 +251,11 @@ class VectorTile extends UrlTile { } else if (state === TileState.ERROR) { tile.errorSourceTileKeys[sourceTileKey] = true; } - if (tile.loadingSourceTiles - Object.keys(tile.errorSourceTileKeys).length === 0) { - tile.hifi = true; + const errorTileCount = Object.keys(tile.errorSourceTileKeys).length; + if (tile.loadingSourceTiles - errorTileCount === 0) { + tile.hifi = errorTileCount === 0; tile.sourceZ = sourceZ; - tile.setState(isEmpty(tile.errorSourceTileKeys) ? TileState.LOADED : TileState.ERROR); + tile.setState(TileState.LOADED); } } }; diff --git a/test/spec/ol/vectorrendertile.test.js b/test/spec/ol/vectorrendertile.test.js index c54579b6ee..6b80b9971e 100644 --- a/test/spec/ol/vectorrendertile.test.js +++ b/test/spec/ol/vectorrendertile.test.js @@ -27,9 +27,11 @@ describe('ol.VectorRenderTile', function() { listen(tile, 'change', function(e) { ++calls; if (calls === 1) { - expect(tile.getState()).to.be(TileState.ERROR); + expect(tile.getState()).to.be(TileState.LOADED); + expect(tile.hifi).to.be(false); setTimeout(function() { sourceTile.setState(TileState.LOADED); + expect(tile.hifi).to.be(true); }, 0); } else if (calls === 2) { done(); @@ -37,7 +39,7 @@ describe('ol.VectorRenderTile', function() { }); }); - it('sets ERROR state when source tiles fail to load', function(done) { + it('sets LOADED state and hifi==false when source tiles fail to load', function(done) { const source = new VectorTileSource({ format: new GeoJSON(), url: 'spec/ol/data/unavailable.json' @@ -47,7 +49,8 @@ describe('ol.VectorRenderTile', function() { tile.load(); listen(tile, 'change', function(e) { - expect(tile.getState()).to.be(TileState.ERROR); + expect(tile.getState()).to.be(TileState.LOADED); + expect(tile.hifi).to.be(false); done(); }); });