Fix: fix updating of styles

This commit is contained in:
Pieter Vander Vennet 2023-10-06 14:41:22 +02:00
parent 6f376291ce
commit 650c1a675c

View file

@ -16,6 +16,7 @@ import { LayerConfigJson } from "../../Models/ThemeConfig/Json/LayerConfigJson"
import PerLayerFeatureSourceSplitter from "../../Logic/FeatureSource/PerLayerFeatureSourceSplitter" import PerLayerFeatureSourceSplitter from "../../Logic/FeatureSource/PerLayerFeatureSourceSplitter"
import FilteredLayer from "../../Models/FilteredLayer" import FilteredLayer from "../../Models/FilteredLayer"
import SimpleFeatureSource from "../../Logic/FeatureSource/Sources/SimpleFeatureSource" import SimpleFeatureSource from "../../Logic/FeatureSource/Sources/SimpleFeatureSource"
import { CLIENT_RENEG_LIMIT } from "tls";
class PointRenderingLayer { class PointRenderingLayer {
private readonly _config: PointRenderingConfig private readonly _config: PointRenderingConfig
@ -229,7 +230,10 @@ class LineRenderingLayer {
const self = this const self = this
features.features.addCallbackAndRunD(() => self.update(features.features)) features.features.addCallbackAndRunD(() => self.update(features.features))
map.on("styledata", () => self.update(features.features)) map.on("styledata", () => {
self._listenerInstalledOn.clear()
return self.update(features.features);
})
} }
public destruct(): void { public destruct(): void {
@ -406,13 +410,10 @@ class LineRenderingLayer {
} else { } else {
const tags = this._fetchStore(id) const tags = this._fetchStore(id)
this._listenerInstalledOn.add(id) this._listenerInstalledOn.add(id)
map.setFeatureState( tags.addCallbackAndRunD((properties) => {
{ source: this._layername, id }, // Make sure to use 'getSource' here, the layer names are different!
this.calculatePropsFor(feature.properties) if(map.getSource(this._layername) === undefined){
) return true
tags.addCallbackD((properties) => {
if (!map.getLayer(this._layername)) {
return
} }
map.setFeatureState( map.setFeatureState(
{ source: this._layername, id }, { source: this._layername, id },