wip: use new request for fetching remote data
This commit is contained in:
parent
8b2778116d
commit
c50be398ab
1 changed files with 6 additions and 11 deletions
|
@ -740,24 +740,19 @@ L.U.DataLayer = L.Evented.extend({
|
||||||
return !((!isNaN(from) && zoom < from) || (!isNaN(to) && zoom > to))
|
return !((!isNaN(from) && zoom < from) || (!isNaN(to) && zoom > to))
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchRemoteData: function (force) {
|
fetchRemoteData: async function (force) {
|
||||||
if (!this.isRemoteLayer()) return
|
if (!this.isRemoteLayer()) return
|
||||||
if (!this.options.remoteData.dynamic && this.hasDataLoaded() && !force) return
|
if (!this.options.remoteData.dynamic && this.hasDataLoaded() && !force) return
|
||||||
if (!this.isVisible()) return
|
if (!this.isVisible()) return
|
||||||
let url = this.map.localizeUrl(this.options.remoteData.url)
|
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)
|
url = this.map.proxyUrl(url, this.options.remoteData.ttl)
|
||||||
this.map.ajax({
|
const response = await this.map.request.get(url)
|
||||||
uri: url,
|
|
||||||
verb: 'GET',
|
|
||||||
callback: (raw) => {
|
|
||||||
this.clear()
|
this.clear()
|
||||||
this.rawToGeoJSON(raw, this.options.remoteData.format, (geojson) =>
|
this.rawToGeoJSON(await response.text(), this.options.remoteData.format, (geojson) =>
|
||||||
this.fromGeoJSON(geojson)
|
this.fromGeoJSON(geojson)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
onceLoaded: function (callback, context) {
|
onceLoaded: function (callback, context) {
|
||||||
if (this.isLoaded()) callback.call(context || this, this)
|
if (this.isLoaded()) callback.call(context || this, this)
|
||||||
|
|
Loading…
Reference in a new issue