From f5d946e665b38a6daf0a19e20b4126cbabaea91f Mon Sep 17 00:00:00 2001 From: MV88 Date: Wed, 25 Oct 2023 11:46:18 +0200 Subject: [PATCH] Fix #9654 updates of feature styles --- .../map/openlayers/plugins/VectorLayer.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/web/client/components/map/openlayers/plugins/VectorLayer.js b/web/client/components/map/openlayers/plugins/VectorLayer.js index ede0243319..b85e404f90 100644 --- a/web/client/components/map/openlayers/plugins/VectorLayer.js +++ b/web/client/components/map/openlayers/plugins/VectorLayer.js @@ -64,7 +64,19 @@ Layers.registerType('vector', { }); } - if (!isEqual(oldOptions.style, newOptions.style) || oldOptions.styleName !== newOptions.styleName) { + /** + * we need to also check when features changes because there could be styles depending of features + * so when the latter changes we have to redraw to redo the checks and apply correct style based on new feature props + */ + const areFeaturesChanged = !isEqual(oldOptions.features, newOptions.features); + + const isStyleChanged = !isEqual(oldOptions.style, newOptions.style); + const isStyleNameChanged = oldOptions.styleName !== newOptions.styleName; + if ( + isStyleChanged || + isStyleNameChanged || + areFeaturesChanged + ) { getStyle(applyDefaultStyleToVectorLayer({ ...newOptions, asPromise: true })) .then((style) => { if (style) {