Skip to content

Commit

Permalink
[GridLayer] redraw tiles properly after changing maxNativeZoom (#6443)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii authored Nov 26, 2021
1 parent 05fa580 commit 2e86387
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/suites/layer/tile/GridLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,18 @@ describe('GridLayer', function () {

map.addLayer(grid);
});

it("redraws tiles properly after changing maxNativeZoom", function () {
var initialZoom = 12;
map.setView([0, 0], initialZoom);

var grid = L.gridLayer().addTo(map);
expect(grid._tileZoom).to.be(initialZoom);

grid.options.maxNativeZoom = 11;
grid.redraw();
expect(grid._tileZoom).to.be(11);
});
});

describe("number of 256px tiles loaded in synchronous non-animated grid @800x600px", function () {
Expand Down
5 changes: 5 additions & 0 deletions src/layer/tile/GridLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ export var GridLayer = Layer.extend({
redraw: function () {
if (this._map) {
this._removeAllTiles();
var tileZoom = this._clampZoom(this._map.getZoom());
if (tileZoom !== this._tileZoom) {
this._tileZoom = tileZoom;
this._updateLevels();
}
this._update();
}
return this;
Expand Down

0 comments on commit 2e86387

Please sign in to comment.