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()
|
const status = this.permissions.getShareStatusDisplay()
|
||||||
name.textContent = this.getDisplayName()
|
name.textContent = this.getDisplayName()
|
||||||
// status is not set until map is saved once
|
// status is not set until map is saved once
|
||||||
if (status) share_status.textContent = L._('Visibility: {status}', {
|
if (status)
|
||||||
status: status,
|
share_status.textContent = L._('Visibility: {status}', {
|
||||||
})
|
status: status,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
update()
|
update()
|
||||||
this.once('saved', L.bind(update, this))
|
this.once('saved', L.bind(update, this))
|
||||||
|
@ -1129,10 +1130,23 @@ L.U.Map.include({
|
||||||
toggleCaveat()
|
toggleCaveat()
|
||||||
const download = L.DomUtil.create('a', 'button', container)
|
const download = L.DomUtil.create('a', 'button', container)
|
||||||
download.textContent = L._('Download data')
|
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 } })
|
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) {
|
download: function (mode) {
|
||||||
const type = this.EXPORT_TYPES[mode || 'umap']
|
const type = this.EXPORT_TYPES[mode || 'umap']
|
||||||
const content = type.formatter(this)
|
const content = type.formatter(this)
|
||||||
|
|
|
@ -379,33 +379,41 @@ L.U.Map.include({
|
||||||
},
|
},
|
||||||
|
|
||||||
initDatalayers: function () {
|
initDatalayers: function () {
|
||||||
let toload = (dataToload = seen = this.options.datalayers.length)
|
for (let j = 0; j < this.options.datalayers.length; j++) {
|
||||||
const self = this
|
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
|
let datalayer
|
||||||
const loaded = () => {
|
const loaded = () => {
|
||||||
self.datalayersLoaded = true
|
this.datalayersLoaded = true
|
||||||
self.fire('datalayersloaded')
|
this.fire('datalayersloaded')
|
||||||
}
|
}
|
||||||
const decrementToLoad = () => {
|
const decrementToLoad = () => {
|
||||||
toload--
|
toload--
|
||||||
if (toload === 0) loaded()
|
if (toload === 0) loaded()
|
||||||
}
|
}
|
||||||
const dataLoaded = () => {
|
const dataLoaded = () => {
|
||||||
self.dataLoaded = true
|
this.dataLoaded = true
|
||||||
self.fire('dataloaded')
|
this.fire('dataloaded')
|
||||||
}
|
}
|
||||||
const decrementDataToLoad = () => {
|
const decrementDataToLoad = () => {
|
||||||
dataToload--
|
dataToload--
|
||||||
if (dataToload === 0) dataLoaded()
|
if (dataToload === 0) dataLoaded()
|
||||||
}
|
}
|
||||||
for (let j = 0; j < this.options.datalayers.length; j++) {
|
this.eachDataLayer(function (datalayer) {
|
||||||
datalayer = this.createDataLayer(this.options.datalayers[j])
|
if (force && !datalayer.hasDataLoaded()) datalayer.show()
|
||||||
if (datalayer.displayedOnLoad()) datalayer.onceLoaded(decrementToLoad)
|
if (datalayer.displayedOnLoad() || force) datalayer.onceLoaded(decrementToLoad)
|
||||||
else decrementToLoad()
|
else decrementToLoad()
|
||||||
if (datalayer.displayedOnLoad()) datalayer.onceDataLoaded(decrementDataToLoad)
|
if (datalayer.displayedOnLoad() || force)
|
||||||
|
datalayer.onceDataLoaded(decrementDataToLoad)
|
||||||
else decrementDataToLoad()
|
else decrementDataToLoad()
|
||||||
}
|
})
|
||||||
if (seen === 0) {
|
if (total === 0) {
|
||||||
// no datalayer
|
// no datalayer
|
||||||
loaded()
|
loaded()
|
||||||
dataLoaded()
|
dataLoaded()
|
||||||
|
|
Loading…
Reference in a new issue