Merge pull request #1390 from umap-project/cluster-race-condition

Fix race condition with cluster layer
This commit is contained in:
Yohan Boniface 2023-11-07 17:39:44 +01:00 committed by GitHub
commit dac15bca95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,6 +60,16 @@ L.U.Layer.Cluster = L.MarkerClusterGroup.extend({
this._layers = []
},
onRemove: function (map) {
// In some situation, the onRemove is called before the layer is really
// added to the map: basically when combining a defaultView=data + max/minZoom
// and loading the map at a zoom outside of that zoom range.
// FIXME: move this upstream (_unbindEvents should accept a map parameter
// instead of relying on this._map)
this._map = map
return L.MarkerClusterGroup.prototype.onRemove.call(this, map)
},
addLayer: function (layer) {
this._layers.push(layer)
return L.MarkerClusterGroup.prototype.addLayer.call(this, layer)