fix: show message in case of xml parsing error

fix #1866
This commit is contained in:
Yohan Boniface 2024-05-29 11:51:47 +02:00
parent 7f3149af08
commit 16ab193b5d

View file

@ -933,7 +933,14 @@ U.DataLayer = L.Evented.extend({
}, },
rawToGeoJSON: function (c, type, callback) { 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 // TODO add a duck typing guessType
if (type === 'csv') { if (type === 'csv') {