From 7cb6c0c45fafc7cbfc167dfca28ca4d695f21313 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Fri, 20 Dec 2024 09:25:25 -0500 Subject: [PATCH] fix(#2391): split zoomTo to accept bounds Since https://github.com/umap-project/umap/commit/de921660c9448066dc810c418811f30e2186282e#diff-4a01a166046bdf7e4ea7d41d97cd82a57c82f63d10d1697f76e6fe22bfa769ebR954 we were calling it with bounds but also with the click event sometimes. --- umap/static/umap/js/modules/data/layer.js | 8 ++++++-- umap/static/umap/js/modules/importer.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index 9edd48a40..a6f77a671 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -950,9 +950,13 @@ export class DataLayer extends ServerStored { else this.hide() } - zoomTo(bounds) { + zoomTo() { if (!this.isVisible()) return - bounds = bounds || this.layer.getBounds() + const bounds = this.layer.getBounds() + this.zoomToBounds(bounds) + } + + zoomToBounds(bounds) { if (bounds.isValid()) { const options = { maxZoom: this.getOption('zoomTo') } this._leafletMap.fitBounds(bounds, options) diff --git a/umap/static/umap/js/modules/importer.js b/umap/static/umap/js/modules/importer.js index 1da6d566b..9d1d6180f 100644 --- a/umap/static/umap/js/modules/importer.js +++ b/umap/static/umap/js/modules/importer.js @@ -382,7 +382,7 @@ export default class Importer extends Utils.WithTemplate { bounds.extend(featureBounds) } this.onSuccess(features.length) - layer.zoomTo(bounds) + layer.zoomToBounds(bounds) } } }