diff --git a/doc/errors/index.md b/doc/errors/index.md index e45f47bd3b..646a6a33b5 100644 --- a/doc/errors/index.md +++ b/doc/errors/index.md @@ -248,4 +248,8 @@ This is done by providing adequate shaders using the `hitVertexShader` and `hitF ### 67 -A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both. \ No newline at end of file +A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both. + +### 68 + +Data from this source can only be rendered if it has a projection compatible with the view projection. \ No newline at end of file diff --git a/src/ol/source/Tile.js b/src/ol/source/Tile.js index 6f21a948cb..36d0080f8e 100644 --- a/src/ol/source/Tile.js +++ b/src/ol/source/Tile.js @@ -6,6 +6,7 @@ import Source from './Source.js'; import TileCache from '../TileCache.js'; import TileState from '../TileState.js'; import {abstract} from '../util.js'; +import {assert} from '../asserts.js'; import {equivalent} from '../proj.js'; import {getKeyZXY, withinExtentAndZ} from '../tilecoord.js'; import { @@ -250,12 +251,11 @@ class TileSource extends Source { * @protected */ getTileCacheForProjection(projection) { - const thisProj = this.getProjection(); - if (thisProj && !equivalent(thisProj, projection)) { - return null; - } else { - return this.tileCache; - } + assert( + equivalent(this.getProjection(), projection), + 68 // A VectorTile source can only be rendered if it has a projection compatible with the view projection. + ); + return this.tileCache; } /**