Set label text for option styles

Set label text for lonLabelStyle and latLabelStyle options
This commit is contained in:
mike-000
2019-10-04 22:00:20 +01:00
committed by GitHub
parent babdce4819
commit b727e4f45e
+4 -4
View File
@@ -332,9 +332,8 @@ class Graticule extends VectorLayer {
const label = feature.get('graticule_label'); const label = feature.get('graticule_label');
if (!this.lonLabelStyleCache_[label]) { if (!this.lonLabelStyleCache_[label]) {
this.lonLabelStyleCache_[label] = new Style({ this.lonLabelStyleCache_[label] = new Style({
text: options.lonLabelStyle !== undefined ? options.lonLabelStyle : text: options.lonLabelStyle !== undefined ? options.lonLabelStyle.clone() :
new Text({ new Text({
text: label,
font: '12px Calibri,sans-serif', font: '12px Calibri,sans-serif',
textBaseline: 'bottom', textBaseline: 'bottom',
fill: new Fill({ fill: new Fill({
@@ -346,6 +345,7 @@ class Graticule extends VectorLayer {
}) })
}) })
}); });
this.lonLabelStyleCache_[label].getText().setText(label);
} }
return this.lonLabelStyleCache_[label]; return this.lonLabelStyleCache_[label];
}.bind(this); }.bind(this);
@@ -365,9 +365,8 @@ class Graticule extends VectorLayer {
const label = feature.get('graticule_label'); const label = feature.get('graticule_label');
if (!this.latLabelStyleCache_[label]) { if (!this.latLabelStyleCache_[label]) {
this.latLabelStyleCache_[label] = new Style({ this.latLabelStyleCache_[label] = new Style({
text: options.latLabelStyle !== undefined ? options.latLabelStyle : text: options.latLabelStyle !== undefined ? options.latLabelStyle.clone() :
new Text({ new Text({
text: label,
font: '12px Calibri,sans-serif', font: '12px Calibri,sans-serif',
textAlign: 'right', textAlign: 'right',
fill: new Fill({ fill: new Fill({
@@ -379,6 +378,7 @@ class Graticule extends VectorLayer {
}) })
}) })
}); });
this.latLabelStyleCache_[label].getText().setText(label);
} }
return this.latLabelStyleCache_[label]; return this.latLabelStyleCache_[label];
}.bind(this); }.bind(this);