From 80b8d5f4c907d9c6423a0ec06219d017f7a8fb39 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 22 Jul 2015 19:37:24 +0300 Subject: [PATCH] improve canvas removeLayer perf, close #3076 --- src/layer/vector/Canvas.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/layer/vector/Canvas.js b/src/layer/vector/Canvas.js index 9b04d03f..ef6fc00c 100644 --- a/src/layer/vector/Canvas.js +++ b/src/layer/vector/Canvas.js @@ -100,12 +100,13 @@ L.Canvas = L.Renderer.extend({ for (var id in this._layers) { layer = this._layers[id]; - if (!this._redrawBounds || layer._pxBounds.intersects(this._redrawBounds)) { - layer._updatePath(); - } + if (clear && layer._removed) { delete layer._removed; delete this._layers[id]; + + } else if (!this._redrawBounds || layer._pxBounds.intersects(this._redrawBounds)) { + layer._updatePath(); } } },