From 8e6c3cf4c28ce58b017ea16a127a4bce860e6a89 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 26 Jul 2018 11:26:00 +0200 Subject: [PATCH] Only change the colors when updating an image style --- contribs/gmf/src/directives/search.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/contribs/gmf/src/directives/search.js b/contribs/gmf/src/directives/search.js index f76ac79503bb..9a35a6113c31 100644 --- a/contribs/gmf/src/directives/search.js +++ b/contribs/gmf/src/directives/search.js @@ -771,13 +771,19 @@ gmf.SearchController.prototype.getSearchStyle_ = function(feature, resolution) { if (fillStyle) { fillStyle.setColor(fillColor); } - const image = style.getImage(); - if (image) { - style.setImage(new ol.style.Circle({ - fill: new ol.style.Fill({color: fillColor}), - radius: 5, - stroke: new ol.style.Stroke({color: strokeColor}) - })); + // the image style can't be changed in place, the colors are updated on a clone. + let imageStyle = style.getImage(); + if (imageStyle) { + imageStyle = imageStyle.clone(); + const imageStrokeStyle = imageStyle.getStroke(); + if (imageStrokeStyle) { + imageStrokeStyle.setColor(strokeColor); + } + const imageFillStyle = imageStyle.getFill(); + if (imageFillStyle) { + imageFillStyle.setColor(fillColor); + } + style.setImage(imageStyle); } } return style;