From c50be398ab55660dd41f5b64329332603e1cf35e Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 24 Jan 2024 12:01:14 +0100 Subject: [PATCH] wip: use new request for fetching remote data --- umap/static/umap/js/umap.layer.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 61218122..bdae1f3a 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -740,23 +740,18 @@ L.U.DataLayer = L.Evented.extend({ return !((!isNaN(from) && zoom < from) || (!isNaN(to) && zoom > to)) }, - fetchRemoteData: function (force) { + fetchRemoteData: async function (force) { if (!this.isRemoteLayer()) return 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) url = this.map.proxyUrl(url, this.options.remoteData.ttl) - this.map.ajax({ - uri: url, - verb: 'GET', - callback: (raw) => { - this.clear() - this.rawToGeoJSON(raw, this.options.remoteData.format, (geojson) => - this.fromGeoJSON(geojson) - ) - }, - }) + const response = await this.map.request.get(url) + this.clear() + this.rawToGeoJSON(await response.text(), this.options.remoteData.format, (geojson) => + this.fromGeoJSON(geojson) + ) }, onceLoaded: function (callback, context) {