From 3089b71705ec3959e895b8e4bf3caabb9a7e8ee6 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sun, 8 Nov 2020 16:49:23 +0100 Subject: [PATCH] Prevent to redraw a marker when setting invalid latlng from edit form cf #799 --- umap/static/umap/js/umap.core.js | 4 ++++ umap/static/umap/js/umap.features.js | 1 + 2 files changed, 5 insertions(+) diff --git a/umap/static/umap/js/umap.core.js b/umap/static/umap/js/umap.core.js index 07bab3cc..9b9d5e01 100644 --- a/umap/static/umap/js/umap.core.js +++ b/umap/static/umap/js/umap.core.js @@ -546,3 +546,7 @@ L.U.Orderable = L.Evented.extend({ } }); + +L.LatLng.prototype.isValid = function () { + return !isNaN(this.lat) && !isNaN(this.lng); +} diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index 54a0394c..ce17aa0d 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -585,6 +585,7 @@ L.U.Marker = L.Marker.extend({ ]; var builder = new L.U.FormBuilder(this, coordinatesOptions, { callback: function () { + if (!this._latlng.isValid()) return; this._redraw(); this.bringToCenter(); },