From e1f91b393d5e6e5bc18550d5a8b50b691cfc2d6c Mon Sep 17 00:00:00 2001 From: David Larlet Date: Wed, 12 Jun 2024 12:54:58 -0400 Subject: [PATCH] chore: do not display zoom alert on save --- umap/static/umap/js/umap.controls.js | 2 +- umap/static/umap/js/umap.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 831aa26c..435f8e3a 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -84,7 +84,7 @@ U.UpdateExtentAction = U.BaseAction.extend({ }, addHooks: function () { - this.map.updateExtent() + this.map.setCenterAndZoom() }, }) diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index bbfee5d1..9cc41025 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -828,16 +828,16 @@ U.Map = L.Map.extend({ return this.getDefaultOption(option) }, - updateExtent: function () { + setCenterAndZoom: function () { + this._setCenterAndZoom() + U.Alert.info(L._('The zoom and center have been modified.')) + }, + + _setCenterAndZoom: function () { this.options.center = this.getCenter() this.options.zoom = this.getZoom() this.isDirty = true this._default_extent = false - if (this.options.umap_id) { - // We do not want an extra message during the map creation - // to avoid the double notification/alert. - U.Alert.info(L._('The zoom and center have been modified.')) - } }, updateTileLayers: function () { @@ -1096,7 +1096,7 @@ U.Map = L.Map.extend({ save: function () { if (!this.isDirty) return - if (this._default_extent) this.updateExtent() + if (this._default_extent) this._setCenterAndZoom() this.backup() this.once('saved', () => { this.isDirty = false