From f829bd0d719cac7d1a361b741ff296255ee6e739 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 2 Nov 2016 13:17:42 -0700 Subject: [PATCH] calculate matrices after constraining (#3518) Fixes #3474. --- js/geo/transform.js | 6 +++--- test/js/geo/transform.test.js | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/js/geo/transform.js b/js/geo/transform.js index e786434132c..fe6fe03b944 100644 --- a/js/geo/transform.js +++ b/js/geo/transform.js @@ -112,8 +112,8 @@ class Transform { this.scale = this.zoomScale(z); this.tileZoom = Math.floor(z); this.zoomFraction = z - this.tileZoom; - this._calcMatrices(); this._constrain(); + this._calcMatrices(); } get center() { return this._center; } @@ -121,8 +121,8 @@ class Transform { if (center.lat === this._center.lat && center.lng === this._center.lng) return; this._unmodified = false; this._center = center; - this._calcMatrices(); this._constrain(); + this._calcMatrices(); } /** @@ -177,8 +177,8 @@ class Transform { this.height = height; this.pixelsToGLUnits = [2 / width, -2 / height]; - this._calcMatrices(); this._constrain(); + this._calcMatrices(); } get unmodified() { return this._unmodified; } diff --git a/test/js/geo/transform.test.js b/test/js/geo/transform.test.js index 03f0417d169..e693a2d9751 100644 --- a/test/js/geo/transform.test.js +++ b/test/js/geo/transform.test.js @@ -45,6 +45,13 @@ test('transform', (t) => { t.end(); }); + t.test('does not throw on bad center', (t) => { + const transform = new Transform(); + transform.resize(500, 500); + transform.center = {lng: 50, lat: -90}; + t.end(); + }); + t.test('panBy', (t) => { const transform = new Transform(); transform.resize(500, 500);