Skip to content

Commit

Permalink
fix TileLayer clear when spatialReference changed, and fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn committed Oct 2, 2022
1 parent fa20b96 commit 4b7aae5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/layer/tile/TileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,9 @@ class TileLayer extends Layer {
if (this._renderer) {
this._renderer.clear();
}
if (this.tileInfoCache) {
this.tileInfoCache.reset();
}
/**
* clear event, fired when tile layer is cleared.
*
Expand Down Expand Up @@ -1282,6 +1285,10 @@ class TileLayer extends Layer {
delete this._sr;
delete this._srMinZoom;
delete this._hasOwnSR;
delete this._rootNodes;
if (this.tileInfoCache) {
this.tileInfoCache.reset();
}
const renderer = this.getRenderer();
if (renderer) {
renderer.clear();
Expand Down
8 changes: 4 additions & 4 deletions test/map/spatial-reference/SpatialRefUpdateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ describe('SpatialReference.Update', function () {
});
var tiles = tileLayer.getTiles().tileGrids[0].tiles;
var tile = tiles[tiles.length - 1];
expect(tile.extent2d.xmin).to.be.eql(-256);
expect(tile.extent2d.ymax).to.be.eql(0);
expect(tile.x).to.be.eql(-1);
expect(tile.y).to.be.eql(0);
done();
});
map.setBaseLayer(tileLayer);
var tiles = tileLayer.getTiles().tileGrids[0].tiles;
var tile = tiles[tiles.length - 1];
expect(tile.extent2d.xmin).to.be.eql(-256);
expect(tile.extent2d.ymax).to.be.eql(256);
expect(tile.x).to.be.eql(8191);
expect(tile.y).to.be.eql(8191);
});

var geometries = GEN_GEOMETRIES_OF_ALL_TYPES();
Expand Down

0 comments on commit 4b7aae5

Please sign in to comment.