Merge pull request #1296 from umap-project/dataloaded-if-not-shown
Fix datalayers not sending "dataloaded" event when min/maxZoom is set and map is loaded outside those values
This commit is contained in:
commit
4289747d93
2 changed files with 11 additions and 5 deletions
|
@ -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()
|
||||
})
|
||||
|
|
|
@ -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 &&
|
||||
|
|
Loading…
Reference in a new issue