From 16ab193b5dfbc3485094cccc8d25ce9d82fc1058 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 29 May 2024 11:51:47 +0200 Subject: [PATCH] fix: show message in case of xml parsing error fix #1866 --- umap/static/umap/js/umap.layer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 02207e81..798b098c 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -933,7 +933,14 @@ U.DataLayer = L.Evented.extend({ }, rawToGeoJSON: function (c, type, callback) { - const toDom = (x) => new DOMParser().parseFromString(x, 'text/xml') + const toDom = (x) => { + const doc = new DOMParser().parseFromString(x, 'text/xml') + const errorNode = doc.querySelector('parsererror') + if (errorNode) { + this.map.alert.open({ content: L._('Cannot parse data'), level: 'error' }) + } + return doc + } // TODO add a duck typing guessType if (type === 'csv') {