Skip to content

Commit d67688e

Browse files
authored
Fix: MVT update min/maXZoom props (visgl#6040)
1 parent d35f058 commit d67688e

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

modules/geo-layers/src/mvt-layer/mvt-layer.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default class MVTLayer extends TileLayer {
4747

4848
/* eslint-disable complexity */
4949
async _updateTileData() {
50-
let {data, minZoom, maxZoom} = this.props;
50+
let {data} = this.props;
5151
let tileJSON = null;
5252

5353
if (typeof data === 'string' && !isURLTemplate(data)) {
@@ -69,21 +69,30 @@ export default class MVTLayer extends TileLayer {
6969

7070
if (tileJSON) {
7171
data = tileJSON.tiles;
72+
}
73+
74+
this.setState({data, tileJSON});
75+
}
76+
77+
_getTilesetOptions(props) {
78+
const opts = super._getTilesetOptions(props);
79+
const {tileJSON} = this.state;
7280

73-
if (Number.isFinite(tileJSON.minzoom) && tileJSON.minzoom > minZoom) {
74-
minZoom = tileJSON.minzoom;
81+
if (tileJSON) {
82+
if (Number.isFinite(tileJSON.minzoom) && tileJSON.minzoom > props.minZoom) {
83+
opts.minZoom = tileJSON.minzoom;
7584
}
7685

7786
if (
7887
Number.isFinite(tileJSON.maxzoom) &&
79-
(!Number.isFinite(maxZoom) || tileJSON.maxzoom < maxZoom)
88+
(!Number.isFinite(props.maxZoom) || tileJSON.maxzoom < props.maxZoom)
8089
) {
81-
maxZoom = tileJSON.maxzoom;
90+
opts.maxZoom = tileJSON.maxzoom;
8291
}
8392
}
84-
85-
this.setState({data, tileJSON, minZoom, maxZoom});
93+
return opts;
8694
}
95+
8796
/* eslint-disable complexity */
8897

8998
renderLayers() {

modules/geo-layers/src/tile-layer/tile-layer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ export default class TileLayer extends CompositeLayer {
8282
}
8383

8484
_getTilesetOptions(props) {
85-
const maxZoom = Number.isFinite(this.state.maxZoom) ? this.state.maxZoom : props.maxZoom;
86-
const minZoom = Number.isFinite(this.state.minZoom) ? this.state.minZoom : props.minZoom;
8785
const {
8886
tileSize,
8987
maxCacheSize,
9088
maxCacheByteSize,
9189
refinementStrategy,
9290
extent,
91+
maxZoom,
92+
minZoom,
9393
maxRequests,
9494
zoomOffset
9595
} = props;

0 commit comments

Comments
 (0)