Allow syncing of layers

This commit is contained in:
Alexis Métaireau 2024-02-19 14:23:16 +01:00
parent 07b1e237cd
commit 1740c45837
3 changed files with 8 additions and 5 deletions

View file

@ -53,7 +53,8 @@ export class DatalayerUpdater extends BaseUpdater {
const datalayer = this.getLayerFromID(metadata.id) const datalayer = this.getLayerFromID(metadata.id)
console.log(datalayer, key, value) console.log(datalayer, key, value)
this.updateObjectValue(datalayer, key, value) this.updateObjectValue(datalayer, key, value)
datalayer.renderProperties([key]) const property = key.replace("options.", "")
datalayer.renderProperties([property])
} }
} }

View file

@ -14,7 +14,7 @@ L.U.DataRendererMixin = {
* *
* @param list properties : properties that have been updated. * @param list properties : properties that have been updated.
*/ */
renderProperties: function (properties, builder) { renderProperties: function (properties) {
let renderers = new Set() let renderers = new Set()
for (const prop of properties) { for (const prop of properties) {
const propRenderers = this.propertiesRenderers[prop] const propRenderers = this.propertiesRenderers[prop]
@ -36,7 +36,9 @@ L.U.DataRendererMixin = {
} }
for (const renderer of renderers) { for (const renderer of renderers) {
this[renderer](properties, builder) if (renderer in this) {
this[renderer](properties)
}
} }
}, },

View file

@ -257,13 +257,13 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({
// If user touches the breaks, then force manual mode // If user touches the breaks, then force manual mode
if (field === 'options.choropleth.breaks') { if (field === 'options.choropleth.breaks') {
this.datalayer.options.choropleth.mode = 'manual' this.datalayer.options.choropleth.mode = 'manual'
builder.helpers['options.choropleth.mode'].fetch() if (builder) builder.helpers['options.choropleth.mode'].fetch()
} }
this.computeBreaks() this.computeBreaks()
// If user changes the mode or the number of classes, // If user changes the mode or the number of classes,
// then update the breaks input value // then update the breaks input value
if (field === 'options.choropleth.mode' || field === 'options.choropleth.classes') { if (field === 'options.choropleth.mode' || field === 'options.choropleth.classes') {
builder.helpers['options.choropleth.breaks'].fetch() if (builder) builder.helpers['options.choropleth.breaks'].fetch()
} }
}, },