From aed9e898e9ed7719cd821f21ec3ce9ffd68855f6 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Tue, 19 Sep 2023 13:56:11 -0400 Subject: [PATCH] Restrict possible min/max zoom values Fix #1318 --- umap/static/umap/base.css | 5 +++++ umap/static/umap/js/umap.js | 29 +++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/base.css b/umap/static/umap/base.css index 05af31bf..5bc48647 100644 --- a/umap/static/umap/base.css +++ b/umap/static/umap/base.css @@ -669,6 +669,11 @@ input[type=hidden].blur + .button { /*box-shadow: inset 0 0 0 1px #215d9c;*/ color: #efefef; } +input:invalid { + border-color: red; + background-color: darkred; +} + /* *********** */ /* Alerts */ diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 27414e33..8537819e 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -14,6 +14,7 @@ L.Map.mergeOptions({ default_popupContentTemplate: '# {name}\n{description}', default_interactive: true, default_labelDirection: 'auto', + maxZoomLimit: 20, attributionControl: false, allowEdit: true, embedControl: true, @@ -1524,11 +1525,21 @@ L.U.Map.include({ ], [ 'options.tilelayer.maxZoom', - { handler: 'BlurIntInput', placeholder: L._('max zoom') }, + { + handler: 'BlurIntInput', + placeholder: L._('max zoom'), + min: 0, + max: this.options.maxZoomLimit, + }, ], [ 'options.tilelayer.minZoom', - { handler: 'BlurIntInput', placeholder: L._('min zoom') }, + { + handler: 'BlurIntInput', + placeholder: L._('min zoom'), + min: 0, + max: this.options.maxZoomLimit, + }, ], [ 'options.tilelayer.attribution', @@ -1563,11 +1574,21 @@ L.U.Map.include({ ], [ 'options.overlay.maxZoom', - { handler: 'BlurIntInput', placeholder: L._('max zoom') }, + { + handler: 'BlurIntInput', + placeholder: L._('max zoom'), + min: 0, + max: this.options.maxZoomLimit, + }, ], [ 'options.overlay.minZoom', - { handler: 'BlurIntInput', placeholder: L._('min zoom') }, + { + handler: 'BlurIntInput', + placeholder: L._('min zoom'), + min: 0, + max: this.options.maxZoomLimit, + }, ], [ 'options.overlay.attribution',