From ea4ff7ec61a06c97a5bebad5fab40d379e62f98e Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 23 Oct 2018 16:41:57 +0200 Subject: [PATCH] Adapt getStyleFunction to new ol5 style function --- src/components/ExportKmlService.js | 8 ++------ src/components/print/PrintLayerService.js | 2 +- src/js/DrawController.js | 6 +++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/ExportKmlService.js b/src/components/ExportKmlService.js index 08be4b97db..70e347cb23 100644 --- a/src/components/ExportKmlService.js +++ b/src/components/ExportKmlService.js @@ -41,13 +41,9 @@ goog.require('ga_browsersniffer_service'); clone.setId(f.getId()); clone.getGeometry().setProperties(f.getGeometry().getProperties()); clone.getGeometry().transform(projection, 'EPSG:4326'); - var styles; // TODO should we test getStyle() too? - if (clone.getStyleFunction()) { - styles = clone.getStyleFunction().call(clone); - } else { - styles = layer.getStyleFunction().call(layer, clone); - } + var styles = clone.getStyleFunction() || layer.getStyleFunction(); + styles = styles(clone); var newStyle = { fill: styles[0].getFill(), stroke: styles[0].getStroke(), diff --git a/src/components/print/PrintLayerService.js b/src/components/print/PrintLayerService.js index 90d90d6ed3..7db85aae93 100644 --- a/src/components/print/PrintLayerService.js +++ b/src/components/print/PrintLayerService.js @@ -286,7 +286,7 @@ goog.require('ga_urlutils_service'); // Get the styles of the feature if (!styles) { if (feature.getStyleFunction()) { - styles = feature.getStyleFunction().call(feature, resolution); + styles = feature.getStyleFunction()(feature, resolution); } else if (layer.getStyleFunction()) { styles = layer.getStyleFunction()(feature, resolution); } diff --git a/src/js/DrawController.js b/src/js/DrawController.js index ed416c0f6a..b83607aa30 100644 --- a/src/js/DrawController.js +++ b/src/js/DrawController.js @@ -191,11 +191,11 @@ goog.require('ga_styles_service'); }); return function(feature, resolution) { - if (!feature.getStyleFunction() || - !feature.getStyleFunction().call(feature, resolution)) { + var styleFunction = feature.getStyleFunction(); + if (!styleFunction || !styleFunction(feature, resolution)) { return [newVertexStyle]; } - var styles = feature.getStyleFunction().call(feature, resolution); + var styles = styleFunction(feature, resolution); // When a feature is selected we apply its current style and the // vertex style. return styles.concat([