mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
refactor(sync): Sync layers creation with map.createDataLayer
utility.
Rather than having it done inside the datalayer itself. This gives us more control.
This commit is contained in:
parent
149a0c1680
commit
f42498d195
4 changed files with 11 additions and 10 deletions
|
@ -51,7 +51,7 @@ export class DataLayerUpdater extends BaseUpdater {
|
|||
upsert({ value }) {
|
||||
// Inserts does not happen (we use multiple updates instead).
|
||||
this.map.createDataLayer(value, false)
|
||||
this.map.render()
|
||||
this.map.render([])
|
||||
}
|
||||
|
||||
update({ key, metadata, value }) {
|
||||
|
|
|
@ -943,8 +943,9 @@ L.FormBuilder.MultiChoice = L.FormBuilder.Element.extend({
|
|||
}
|
||||
const choices = this.getChoices().map(([value, label]) => value)
|
||||
if (choices.includes(value)) {
|
||||
this.container.querySelector(`input[type="radio"][value="${value}"]`).checked =
|
||||
true
|
||||
this.container.querySelector(
|
||||
`input[type="radio"][value="${value}"]`
|
||||
).checked = true
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -808,7 +808,12 @@ U.Map = L.Map.extend({
|
|||
datalayer = datalayer || {
|
||||
name: `${L._('Layer')} ${this.datalayers_index.length + 1}`,
|
||||
}
|
||||
return new U.DataLayer(this, datalayer, sync)
|
||||
const dl = new U.DataLayer(this, datalayer, sync)
|
||||
|
||||
if (sync !== false) {
|
||||
dl.sync.upsert(dl.options)
|
||||
}
|
||||
return dl
|
||||
},
|
||||
|
||||
newDataLayer: function () {
|
||||
|
|
|
@ -606,18 +606,13 @@ U.DataLayer = L.Evented.extend({
|
|||
// be in the "forced visibility" mode
|
||||
if (this.autoLoaded()) this.map.on('zoomend', this.onZoomEnd, this)
|
||||
this.on('datachanged', this.map.onDataLayersChanged, this.map)
|
||||
|
||||
if (sync !== false) {
|
||||
const { engine, subject, metadata } = this.getSyncMetadata()
|
||||
engine.upsert(subject, metadata, this.options)
|
||||
}
|
||||
},
|
||||
|
||||
getSyncMetadata: function () {
|
||||
return {
|
||||
subject: 'datalayer',
|
||||
metadata: {
|
||||
id: this.umap_id,
|
||||
id: this.umap_id || null,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue