diff --git a/src/map/Map.js b/src/map/Map.js index 6f0e2bc33..d85c9c1ef 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -1998,6 +1998,7 @@ class Map extends Handlerable(Eventable(Renderable(Class))) { this._zoomLevel = minZoom; } delete this._prjCenter; + delete this._glRes; const projection = this.getProjection(); this._prjCenter = projection.project(this._center); this._calcMatrices(); @@ -2591,7 +2592,7 @@ Map.include(/** @lends Map.prototype */{ const DEFAULT_CENTER = new Coordinate(0, 40); const POINT = new Point(0, 0); return function (altitude = 0, res, originCenter) { - if (this._altitudeOriginDirty) { + if (this._altitudeOriginDirty) { DEFAULT_CENTER.x = this._originLng; this._altitudeOriginDirty = false; } diff --git a/test/map/MapSpec.js b/test/map/MapSpec.js index 1f09d1d15..004cb3635 100644 --- a/test/map/MapSpec.js +++ b/test/map/MapSpec.js @@ -899,13 +899,23 @@ describe('Map.Spec', function () { it('#centercross when map.layers=0', function () { //clear all layers map.removeLayer(baseLayer); - map.options.centerCross=true; - map.once('frameend',function(){ - expect(map).to.be.painted(0, 0); - map.options.centerCross=false; - map.once('frameend',function(){ - expect(map).not.to.be.painted(0, 0); + map.options.centerCross = true; + map.once('frameend', function () { + expect(map).to.be.painted(0, 0); + map.options.centerCross = false; + map.once('frameend', function () { + expect(map).not.to.be.painted(0, 0); }) }) }); + + it('#2128 clear glRes cache when SpatialReference change', function (done) { + //clear all layers + const glRes = map.getGLRes(); + map.setSpatialReference({ projection:'EPSG:4326' }); + setTimeout(() => { + expect(map.getGLRes()).not.to.be(glRes); + done(); + }, 100); + }); });