Skip to content

Commit

Permalink
fix glRes cache not clear when SpatialReference changed (#2132)
Browse files Browse the repository at this point in the history
  • Loading branch information
deyihu authored Dec 19, 2023
1 parent ba07a17 commit a4b9f17
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 16 additions & 6 deletions test/map/MapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit a4b9f17

Please sign in to comment.