VectorTile source projection has to match the view projection

This commit is contained in:
Andreas Hocevar
2020-08-23 12:37:52 +02:00
parent 83055add03
commit 792e15124d
2 changed files with 16 additions and 2 deletions

View File

@@ -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.
A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both.
### 68
A VectorTile source can only be rendered if it has a projection compatible with the view projection.

View File

@@ -20,6 +20,7 @@ import {
scale as scaleTransform,
translate as translateTransform,
} from '../../transform.js';
import {assert} from '../../asserts.js';
import {
buffer,
containsCoordinate,
@@ -34,6 +35,7 @@ import {
createHitDetectionImageData,
hitDetect,
} from '../../render/canvas/hitdetect.js';
import {equivalent} from '../../proj.js';
import {
getSquaredTolerance as getSquaredRenderTolerance,
renderFeature,
@@ -230,7 +232,15 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
* @return {boolean} Layer is ready to be rendered.
*/
prepareFrame(frameState) {
const layerRevision = this.getLayer().getRevision();
const layer = this.getLayer();
assert(
equivalent(
layer.getSource().getProjection(),
frameState.viewState.projection
),
68 // A VectorTile source can only be rendered if it has a projection compatible with the view projection.
);
const layerRevision = layer.getRevision();
if (this.renderedLayerRevision_ != layerRevision) {
this.renderedTiles.length = 0;
}