From b727e4f45e3fa4ab41496edc695dbc34053b831d Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Fri, 4 Oct 2019 22:00:20 +0100 Subject: [PATCH] Set label text for option styles Set label text for lonLabelStyle and latLabelStyle options --- src/ol/layer/Graticule.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ol/layer/Graticule.js b/src/ol/layer/Graticule.js index e237ac85c8..ccca2201fe 100644 --- a/src/ol/layer/Graticule.js +++ b/src/ol/layer/Graticule.js @@ -332,9 +332,8 @@ class Graticule extends VectorLayer { const label = feature.get('graticule_label'); if (!this.lonLabelStyleCache_[label]) { this.lonLabelStyleCache_[label] = new Style({ - text: options.lonLabelStyle !== undefined ? options.lonLabelStyle : + text: options.lonLabelStyle !== undefined ? options.lonLabelStyle.clone() : new Text({ - text: label, font: '12px Calibri,sans-serif', textBaseline: 'bottom', fill: new Fill({ @@ -346,6 +345,7 @@ class Graticule extends VectorLayer { }) }) }); + this.lonLabelStyleCache_[label].getText().setText(label); } return this.lonLabelStyleCache_[label]; }.bind(this); @@ -365,9 +365,8 @@ class Graticule extends VectorLayer { const label = feature.get('graticule_label'); if (!this.latLabelStyleCache_[label]) { this.latLabelStyleCache_[label] = new Style({ - text: options.latLabelStyle !== undefined ? options.latLabelStyle : + text: options.latLabelStyle !== undefined ? options.latLabelStyle.clone() : new Text({ - text: label, font: '12px Calibri,sans-serif', textAlign: 'right', fill: new Fill({ @@ -379,6 +378,7 @@ class Graticule extends VectorLayer { }) }) }); + this.latLabelStyleCache_[label].getText().setText(label); } return this.latLabelStyleCache_[label]; }.bind(this);