diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 7848add6..c8d4ff6e 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -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() }) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 46d1fee7..c829a23f 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -253,13 +253,15 @@ L.U.DataLayer = L.Evented.extend({ // Retrocompat if (this.options.remoteData && this.options.remoteData.from) { this.options.fromZoom = this.options.remoteData.from + delete this.options.remoteData.from } if (this.options.remoteData && this.options.remoteData.to) { this.options.toZoom = this.options.remoteData.to + delete this.options.remoteData.to } 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 () { @@ -268,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) { @@ -281,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 &&