fix: catch cluster error at zoom in certain situation (#2464)
Some checks are pending
Test & Docs / docs (push) Waiting to run
Test & Docs / lint (push) Waiting to run
Test & Docs / tests (postgresql, 3.10) (push) Waiting to run
Test & Docs / tests (postgresql, 3.12) (push) Waiting to run

Eg. to reproduce: a map with a limitBounds that makes uMap immediately
zoom to fit the bbox.
This commit is contained in:
Yohan Boniface 2025-01-30 18:49:19 +01:00 committed by GitHub
commit 48f4daf419
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,7 +63,17 @@ export const Cluster = L.MarkerClusterGroup.extend({
addLayer: function (layer) {
this._layers.push(layer)
try {
return L.MarkerClusterGroup.prototype.addLayer.call(this, layer)
} catch (error) {
console.debug(error)
// Certainly a race condition when loading a clustered layer
// while zooming (this for example can happen at load, when the
// initial zoom is changed by uMap).
// FIXME: remove when this is merged:
// https://github.com/Leaflet/Leaflet.markercluster/pull/1048/files
return this
}
},
removeLayer: function (layer) {