Skip to content

Commit

Permalink
GridLayer: fix _updateLevels and _removeTilesAtZoom (#7123)
Browse files Browse the repository at this point in the history
Because of particular quality of `for ... in` loop, type of `z` is 'string'.
Thus condition `z === zoom` never met in _updateLevels.
Considering wrong arg type, _removeTilesAtZoom also never had any action.

Cleaner solution would be to iterate `Object.keys()` instead, but it is available only since IE 9.
  • Loading branch information
johnd0e committed May 4, 2020
1 parent e7a5c6f commit ec35ab5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/layer/tile/GridLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ export var GridLayer = Layer.extend({
if (zoom === undefined) { return undefined; }

for (var z in this._levels) {
z = Number(z);
if (this._levels[z].el.children.length || z === zoom) {
this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z);
this._onUpdateLevel(z);
Expand Down Expand Up @@ -461,7 +462,7 @@ export var GridLayer = Layer.extend({
_invalidateAll: function () {
for (var z in this._levels) {
DomUtil.remove(this._levels[z].el);
this._onRemoveLevel(z);
this._onRemoveLevel(Number(z));
delete this._levels[z];
}
this._removeAllTiles();
Expand Down

0 comments on commit ec35ab5

Please sign in to comment.