Merge pull request #1298 from umap-project/fix-remotelayer-with-zoom-onload

Try to fix remote datalayer not sending dataloaded
This commit is contained in:
Yohan Boniface 2023-09-08 16:02:37 +02:00 committed by GitHub
commit aa1b04b3ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View file

@ -406,12 +406,19 @@ L.U.Map.include({
if (dataToload === 0) dataLoaded() if (dataToload === 0) dataLoaded()
} }
this.eachDataLayer(function (datalayer) { this.eachDataLayer(function (datalayer) {
if (force && !datalayer.hasDataLoaded()) datalayer.show() if (force && !datalayer.hasDataLoaded()) {
if (datalayer.showAtLoad() || force) datalayer.onceLoaded(decrementToLoad) datalayer.show()
else decrementToLoad() }
if (datalayer.showAtLoad() || force) if (datalayer.showAtLoad() || force) {
datalayer.onceLoaded(decrementToLoad)
} else {
decrementToLoad()
}
if (datalayer.showAtLoad() || force) {
datalayer.onceDataLoaded(decrementDataToLoad) datalayer.onceDataLoaded(decrementDataToLoad)
else decrementDataToLoad() } else {
decrementDataToLoad({ sourceTarget: datalayer })
}
}) })
if (total === 0) { if (total === 0) {
// no datalayer // no datalayer

View file

@ -274,7 +274,7 @@ L.U.DataLayer = L.Evented.extend({
}, },
onMoveEnd: function (e) { onMoveEnd: function (e) {
if (this.isRemoteLayer()) this.fetchRemoteData() if (this.isRemoteLayer() && this.showAtZoom()) this.fetchRemoteData()
}, },
onZoomEnd: function (e) { onZoomEnd: function (e) {
@ -409,7 +409,6 @@ L.U.DataLayer = L.Evented.extend({
fetchRemoteData: function (force) { fetchRemoteData: function (force) {
if (!this.isRemoteLayer()) return if (!this.isRemoteLayer()) return
if (!this.showAtZoom()) 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)