From 44910f5410976a635d3f07a60f541aff4d2adf40 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 26 Sep 2023 10:49:01 +0200 Subject: [PATCH] Do no try to fit data bounds if bounds are not valid This may happen if: - the map as some layers containing data, but set as not browsable - any other layer is empty --- umap/static/umap/js/umap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index eceb2073..77e97aa6 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -672,11 +672,12 @@ L.U.Map.include({ this._controls.locate.start() } else if (this.options.defaultView === 'data') { this.onceDataLoaded(() => { - if (!this.hasData()) { + const bounds = this.getLayersBounds() + if (!this.hasData() || !bounds.isValid()) { this._setDefaultCenter() return } - this.fitBounds(this.getLayersBounds()) + this.fitBounds(bounds) }) } else if (this.options.defaultView === 'latest') { this.onceDataLoaded(() => {