Fix datalayers with min/maxZoom never sending dataloaded event

This commit is contained in:
Yohan Boniface 2023-09-01 12:03:19 +02:00
parent 1b60b46a3f
commit d89d2287b9
2 changed files with 9 additions and 5 deletions

View file

@ -407,9 +407,9 @@ L.U.Map.include({
}
this.eachDataLayer(function (datalayer) {
if (force && !datalayer.hasDataLoaded()) datalayer.show()
if (datalayer.displayedOnLoad() || force) datalayer.onceLoaded(decrementToLoad)
if (datalayer.showAtLoad() || force) datalayer.onceLoaded(decrementToLoad)
else decrementToLoad()
if (datalayer.displayedOnLoad() || force)
if (datalayer.showAtLoad() || force)
datalayer.onceDataLoaded(decrementDataToLoad)
else decrementDataToLoad()
})

View file

@ -261,7 +261,7 @@ L.U.DataLayer = L.Evented.extend({
}
this.backupOptions()
this.connectToMap()
if (this.displayedOnLoad() && this.showAtZoom()) this.show()
if (this.showAtLoad()) this.show()
if (!this.umap_id) this.isDirty = true
this.onceLoaded(function () {
@ -270,7 +270,7 @@ L.U.DataLayer = L.Evented.extend({
// Only layers that are displayed on load must be hidden/shown
// Automatically, others will be shown manually, and thus will
// be in the "forced visibility" mode
if (this.displayedOnLoad()) this.map.on('zoomend', this.onZoomEnd, this)
if (this.autoLoaded()) this.map.on('zoomend', this.onZoomEnd, this)
},
onMoveEnd: function (e) {
@ -283,7 +283,11 @@ L.U.DataLayer = L.Evented.extend({
if (this.showAtZoom() && !this.isVisible()) this.show()
},
displayedOnLoad: function () {
showAtLoad: function () {
return this.autoLoaded() && this.showAtZoom()
},
autoLoaded: function () {
return (
(this.map.datalayersOnLoad &&
this.umap_id &&