From 1e8c51b0e5a7506cf08c999dc69f750b4612fea8 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 12 Oct 2023 11:06:14 +0200 Subject: [PATCH] Add back HeatLayer._map reference check In some situation, the property is undefined, given the call is async, and we can add/remove the layer during the async stack --- umap/static/umap/js/umap.layer.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index accc9a90..1200f8c2 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -374,6 +374,14 @@ L.U.Layer.Heat = L.HeatLayer.extend({ this._updateOptions() }, + redraw: function () { + // setlalngs call _redraw through setAnimFrame, thus async, so this + // can ends with race condition if we remove the layer very faslty after. + // TODO: PR in upstream Leaflet.heat + if (!this._map) return + L.HeatLayer.prototype.redraw.call(this) + }, + _redraw: function () { // Import patch from https://github.com/Leaflet/Leaflet.heat/pull/78 // Remove me when this get merged and released.