parent
3d32bf206b
commit
bf66036b7b
2 changed files with 38 additions and 16 deletions
|
@ -986,9 +986,10 @@ L.U.Map.include({
|
|||
const status = this.permissions.getShareStatusDisplay()
|
||||
name.textContent = this.getDisplayName()
|
||||
// status is not set until map is saved once
|
||||
if (status) share_status.textContent = L._('Visibility: {status}', {
|
||||
status: status,
|
||||
})
|
||||
if (status)
|
||||
share_status.textContent = L._('Visibility: {status}', {
|
||||
status: status,
|
||||
})
|
||||
}
|
||||
update()
|
||||
this.once('saved', L.bind(update, this))
|
||||
|
@ -1129,10 +1130,23 @@ L.U.Map.include({
|
|||
toggleCaveat()
|
||||
const download = L.DomUtil.create('a', 'button', container)
|
||||
download.textContent = L._('Download data')
|
||||
L.DomEvent.on(download, 'click', () => this.download(typeInput.value), this)
|
||||
L.DomEvent.on(
|
||||
download,
|
||||
'click',
|
||||
() => {
|
||||
if (typeInput.value === 'umap') this.fullDownload()
|
||||
else this.download(typeInput.value)
|
||||
}
|
||||
)
|
||||
this.ui.openPanel({ data: { html: container } })
|
||||
},
|
||||
|
||||
fullDownload: function () {
|
||||
// Make sure all data is loaded before downloading
|
||||
this.once('dataloaded', () => this.download())
|
||||
this.loadDatalayers(true) // Force load
|
||||
},
|
||||
|
||||
download: function (mode) {
|
||||
const type = this.EXPORT_TYPES[mode || 'umap']
|
||||
const content = type.formatter(this)
|
||||
|
|
|
@ -379,33 +379,41 @@ L.U.Map.include({
|
|||
},
|
||||
|
||||
initDatalayers: function () {
|
||||
let toload = (dataToload = seen = this.options.datalayers.length)
|
||||
const self = this
|
||||
for (let j = 0; j < this.options.datalayers.length; j++) {
|
||||
this.createDataLayer(this.options.datalayers[j])
|
||||
}
|
||||
this.loadDatalayers()
|
||||
},
|
||||
|
||||
loadDatalayers: function (force) {
|
||||
force = force || L.Util.queryString('download') // In case we are in download mode, let's go strait to loading all data
|
||||
let toload = (dataToload = total = this.datalayers_index.length)
|
||||
let datalayer
|
||||
const loaded = () => {
|
||||
self.datalayersLoaded = true
|
||||
self.fire('datalayersloaded')
|
||||
this.datalayersLoaded = true
|
||||
this.fire('datalayersloaded')
|
||||
}
|
||||
const decrementToLoad = () => {
|
||||
toload--
|
||||
if (toload === 0) loaded()
|
||||
}
|
||||
const dataLoaded = () => {
|
||||
self.dataLoaded = true
|
||||
self.fire('dataloaded')
|
||||
this.dataLoaded = true
|
||||
this.fire('dataloaded')
|
||||
}
|
||||
const decrementDataToLoad = () => {
|
||||
dataToload--
|
||||
if (dataToload === 0) dataLoaded()
|
||||
}
|
||||
for (let j = 0; j < this.options.datalayers.length; j++) {
|
||||
datalayer = this.createDataLayer(this.options.datalayers[j])
|
||||
if (datalayer.displayedOnLoad()) datalayer.onceLoaded(decrementToLoad)
|
||||
this.eachDataLayer(function (datalayer) {
|
||||
if (force && !datalayer.hasDataLoaded()) datalayer.show()
|
||||
if (datalayer.displayedOnLoad() || force) datalayer.onceLoaded(decrementToLoad)
|
||||
else decrementToLoad()
|
||||
if (datalayer.displayedOnLoad()) datalayer.onceDataLoaded(decrementDataToLoad)
|
||||
if (datalayer.displayedOnLoad() || force)
|
||||
datalayer.onceDataLoaded(decrementDataToLoad)
|
||||
else decrementDataToLoad()
|
||||
}
|
||||
if (seen === 0) {
|
||||
})
|
||||
if (total === 0) {
|
||||
// no datalayer
|
||||
loaded()
|
||||
dataLoaded()
|
||||
|
|
Loading…
Reference in a new issue