feat(sync): initialize datalayers internal objects in the constructor.

Otherwise, an event can come from the websocket, trying to update an
`undefined` property.
This commit is contained in:
Alexis Métaireau 2024-04-30 00:23:36 +02:00
parent b956101d5d
commit 9a74cc370c
2 changed files with 8 additions and 7 deletions

View file

@ -48,7 +48,7 @@ export class MapUpdater extends BaseUpdater {
export class DatalayerUpdater extends BaseUpdater {
update({ key, metadata, value }) {
const datalayer = this.getLayerFromID(metadata.id)
console.log(datalayer, key, value)
console.log('datalayer', datalayer, key, value)
this.updateObjectValue(datalayer, key, value)
datalayer.render([key])
}

View file

@ -74,6 +74,10 @@ U.Layer.Cluster = L.MarkerClusterGroup.extend({
L.MarkerClusterGroup.prototype.initialize.call(this, options)
this._markerCluster = U.MarkerCluster
this._layers = []
if (!U.Utils.isObject(this.datalayer.options.cluster)) {
this.datalayer.options.cluster = {}
}
},
onRemove: function (map) {
@ -97,9 +101,6 @@ U.Layer.Cluster = L.MarkerClusterGroup.extend({
},
getEditableOptions: function () {
if (!U.Utils.isObject(this.datalayer.options.cluster)) {
this.datalayer.options.cluster = {}
}
return [
[
'options.cluster.radius',
@ -351,6 +352,9 @@ U.Layer.Heat = L.HeatLayer.extend({
initialize: function (datalayer) {
this.datalayer = datalayer
L.HeatLayer.prototype.initialize.call(this, [], this.datalayer.options.heat)
if (!U.Utils.isObject(this.datalayer.options.heat)) {
this.datalayer.options.heat = {}
}
},
addLayer: function (layer) {
@ -383,9 +387,6 @@ U.Layer.Heat = L.HeatLayer.extend({
},
getEditableOptions: function () {
if (!U.Utils.isObject(this.datalayer.options.heat)) {
this.datalayer.options.heat = {}
}
return [
[
'options.heat.radius',