diff --git a/src/ui/map.ts b/src/ui/map.ts index 1a8aab7783f..46c31d0f80f 100644 --- a/src/ui/map.ts +++ b/src/ui/map.ts @@ -424,7 +424,7 @@ const defaultOptions: Readonly> = { maxTileCacheZoomLevels: config.MAX_TILE_CACHE_ZOOM_LEVELS, transformRequest: null, transformCameraUpdate: null, - fadeDuration: 300, + fadeDuration: 0, crossSourceCollisions: true, clickTolerance: 3, localIdeographFontFamily: 'sans-serif', @@ -676,9 +676,17 @@ export class Map extends Camera { this._setupContainer(); this._setupPainter(); - this.on('move', () => this._update(false)) - .on('moveend', () => this._update(false)) - .on('zoom', () => this._update(true)) + this.on('moveend', () => { + if (!this.style || !this.style.sourceCaches || !this.transform) { + return; + } + for (const id in this.style.sourceCaches) { + this.style.sourceCaches[id].update(this.transform, this.terrain); + } + if (this.areTilesLoaded()) { + this._update(false); + } + }) .on('terrain', () => { this.painter.terrainFacilitator.dirty = true; this._update(true); @@ -745,6 +753,9 @@ export class Map extends Camera { } }); this.on('data', (event: MapDataEvent) => { + if (!this.areTilesLoaded()) { + return; + } this._update(event.dataType === 'style'); this.fire(new Event(`${event.dataType}data`, event)); }); @@ -3226,6 +3237,10 @@ export class Map extends Camera { this._placementDirty = this.style && this.style._updatePlacement(this.transform, this.showCollisionBoxes, fadeDuration, this._crossSourceCollisions, transformUpdateResult.forcePlacementUpdate); + if (this._placementDirty) { + return this._render(paintStartTimeStamp); + } + if (transformUpdateResult.fireProjectionEvent) { this.fire(new Event('projectiontransition', transformUpdateResult.fireProjectionEvent)); }