diff --git a/CHANGELOG.md b/CHANGELOG.md index ad104f3a00..bed8616093 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,12 +11,14 @@ ### 🐞 Bug fixes - *...Add new stuff here...* +- Fix `getElevation()` causing uncaught error ([#1650](https://github.com/maplibre/maplibre-gl-js/issues/1650)). - Add dev version for csp build ([#1730](https://github.com/maplibre/maplibre-gl-js/pull/1730)) - Fix headless benchmark execution especially on VM ([#1732](https://github.com/maplibre/maplibre-gl-js/pull/1732)) - fix issue [#860](https://github.com/maplibre/maplibre-gl-js/issues/860) fill-pattern with pixelRatio > 1 is now switched correctly at runtime. ([#1765](https://github.com/maplibre/maplibre-gl-js/pull/1765)) - Fix the exception that would be thrown on `map.setStyle` when it is passed with transformStyle option and map is initialized without an initial style. ([#1824](https://github.com/maplibre/maplibre-gl-js/pull/1824)) - fix issue [#1582](https://github.com/maplibre/maplibre-gl-js/issues/1582) source maps are now properly generated + ## 3.0.0-pre.1 ### ✨ Features and improvements diff --git a/src/geo/transform.test.ts b/src/geo/transform.test.ts index 079bb4a295..34c24b1df7 100644 --- a/src/geo/transform.test.ts +++ b/src/geo/transform.test.ts @@ -75,6 +75,18 @@ describe('transform', () => { expect(transform.tileZoom).toBe(transform.zoom); }); + test('set zoom inits tileZoom with zoom value', () => { + const transform = new Transform(0, 22, 0, 60); + transform.zoom = 5; + expect(transform.tileZoom).toBe(5); + }); + + test('set zoom clamps tileZoom to non negative value ', () => { + const transform = new Transform(-2, 22, 0, 60); + transform.zoom = -2; + expect(transform.tileZoom).toBe(0); + }); + test('set fov', () => { const transform = new Transform(0, 22, 0, 60, true); transform.fov = 10; diff --git a/src/geo/transform.ts b/src/geo/transform.ts index c1602bea9b..f1a8f34da0 100644 --- a/src/geo/transform.ts +++ b/src/geo/transform.ts @@ -29,7 +29,6 @@ class Transform { height: number; angle: number; rotationMatrix: mat2; - zoomFraction: number; pixelsToGLUnits: [number, number]; cameraToCenterDistance: number; cameraToSeaLevelDistance: number; @@ -196,13 +195,12 @@ class Transform { get zoom(): number { return this._zoom; } set zoom(zoom: number) { - const z = Math.min(Math.max(zoom, this.minZoom), this.maxZoom); - if (this._zoom === z) return; + const constrainedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom); + if (this._zoom === constrainedZoom) return; this._unmodified = false; - this._zoom = z; - this.scale = this.zoomScale(z); - this.tileZoom = Math.floor(z); - this.zoomFraction = z - this.tileZoom; + this._zoom = constrainedZoom; + this.tileZoom = Math.max(0, Math.floor(constrainedZoom)); + this.scale = this.zoomScale(constrainedZoom); this._constrain(); this._calcMatrices(); }