Skip to content

Commit

Permalink
fix: catch cluster error at zoom in certain situation (#2464)
Browse files Browse the repository at this point in the history
Eg. to reproduce: a map with a limitBounds that makes uMap immediately
zoom to fit the bbox.
  • Loading branch information
yohanboniface authored Jan 30, 2025
2 parents e6db23d + a18b240 commit 48f4daf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion umap/static/umap/js/modules/rendering/layers/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ export const Cluster = L.MarkerClusterGroup.extend({

addLayer: function (layer) {
this._layers.push(layer)
return L.MarkerClusterGroup.prototype.addLayer.call(this, 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) {
Expand Down

0 comments on commit 48f4daf

Please sign in to comment.