Remove label style caches

This commit is contained in:
mike-000
2019-10-22 12:04:06 +01:00
committed by GitHub
parent 7edd10d66f
commit 110c17cf9e
+22 -28
View File
@@ -318,20 +318,10 @@ class Graticule extends VectorLayer {
options.latLabelPosition;
/**
* @type {Object.<string,Style>}
* @type {Style}
* @private
*/
this.lonLabelStyleCache_ = {};
/**
* @private
* @param {import("../Feature").default} feature Feature
* @return {Style} style
*/
this.lonLabelStyle_ = function(feature) {
const label = feature.get('graticule_label');
if (!this.lonLabelStyleCache_[label]) {
this.lonLabelStyleCache_[label] = new Style({
this.lonLabelStyleBase_ = new Style({
text: options.lonLabelStyle !== undefined ? options.lonLabelStyle.clone() :
new Text({
font: '12px Calibri,sans-serif',
@@ -345,26 +335,23 @@ class Graticule extends VectorLayer {
})
})
});
this.lonLabelStyleCache_[label].getText().setText(label);
}
return this.lonLabelStyleCache_[label];
}.bind(this);
/**
* @type {Object.<string,Style>}
* @private
*/
this.latLabelStyleCache_ = {};
/**
* @private
* @param {import("../Feature").default} feature Feature
* @return {Style} style
*/
this.latLabelStyle_ = function(feature) {
this.lonLabelStyle_ = function(feature) {
const label = feature.get('graticule_label');
if (!this.latLabelStyleCache_[label]) {
this.latLabelStyleCache_[label] = new Style({
this.lonLabelStyleBase_.getText().setText(label);
return this.lonLabelStyleBase_;
}.bind(this);
/**
* @type {Style}
* @private
*/
this.latLabelStyleBase_ = new Style({
text: options.latLabelStyle !== undefined ? options.latLabelStyle.clone() :
new Text({
font: '12px Calibri,sans-serif',
@@ -378,9 +365,16 @@ class Graticule extends VectorLayer {
})
})
});
this.latLabelStyleCache_[label].getText().setText(label);
}
return this.latLabelStyleCache_[label];
/**
* @private
* @param {import("../Feature").default} feature Feature
* @return {Style} style
*/
this.latLabelStyle_ = function(feature) {
const label = feature.get('graticule_label');
this.latLabelStyleBase_.getText().setText(label);
return this.latLabelStyleBase_;
}.bind(this);
this.meridiansLabels_ = [];