Merge pull request #9873 from ahocevar/another-vectortile-load-fix

Only check extent when a url tile coordinate is available
This commit is contained in:
Andreas Hocevar
2019-08-20 11:08:04 +02:00
committed by GitHub
2 changed files with 15 additions and 1 deletions

View File

@@ -334,7 +334,7 @@ class VectorTile extends UrlTile {
const tileCoord = [z, x, y];
let urlTileCoord = this.getTileCoordForTileUrlFunction(tileCoord, projection);
const sourceExtent = this.getTileGrid().getExtent();
if (sourceExtent) {
if (urlTileCoord && sourceExtent) {
const tileGrid = this.getTileGridForProjection(projection);
const tileExtent = tileGrid.getTileCoordExtent(urlTileCoord);
// make extent 1 pixel smaller so we don't load tiles for < 0.5 pixel render space

View File

@@ -95,6 +95,20 @@ describe('ol.source.VectorTile', function() {
expect(tile.getState()).to.be(TileState.EMPTY);
});
it('creates empty tiles outside the world extent when wrapX === false', function() {
const source = new VectorTileSource({
wrapX: false
});
const tile = source.getTile(0, -1, 0, 1, source.getProjection());
expect(tile.getState()).to.be(TileState.EMPTY);
});
it('creates non-empty tiles outside the world extent when wrapX === true', function() {
const source = new VectorTileSource({});
const tile = source.getTile(0, -1, 0, 1, source.getProjection());
expect(tile.getState()).to.be(TileState.IDLE);
});
it('creates new tile when source key changes', function() {
source.setKey('key1');
const tile1 = source.getTile(0, 0, 0, 1, getProjection('EPSG:3857'));