diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 3c6877d9..9dd8d8c4 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -747,15 +747,18 @@ L.U.DataLayer = L.Evented.extend({ if (!this.options.remoteData.dynamic && this.hasDataLoaded() && !force) return if (!this.isVisible()) return let url = this.map.localizeUrl(this.options.remoteData.url) - if (this.options.remoteData.proxy) + if (this.options.remoteData.proxy) { url = this.map.proxyUrl(url, this.options.remoteData.ttl) + } const response = await this.map.request.get(url) - this.clear() - this.rawToGeoJSON( - await response.text(), - this.options.remoteData.format, - (geojson) => this.fromGeoJSON(geojson) - ) + if (response && response.ok) { + this.clear() + this.rawToGeoJSON( + await response.text(), + this.options.remoteData.format, + (geojson) => this.fromGeoJSON(geojson) + ) + } }, onceLoaded: function (callback, context) { @@ -1060,7 +1063,9 @@ L.U.DataLayer = L.Evented.extend({ importFromUrl: async function (uri, type) { uri = this.map.localizeUrl(uri) const response = await this.map.request.get(uri) - this.importRaw(await response.text(), type) + if (response && response.ok) { + this.importRaw(await response.text(), type) + } }, getColor: function () { diff --git a/umap/views.py b/umap/views.py index c6a4cede..f4484269 100644 --- a/umap/views.py +++ b/umap/views.py @@ -335,7 +335,6 @@ showcase = MapsShowCase.as_view() def validate_url(request): assert request.method == "GET" - assert is_ajax(request) url = request.GET.get("url") assert url try: