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; options.latLabelPosition;
/** /**
* @type {Object.<string,Style>} * @type {Style}
* @private * @private
*/ */
this.lonLabelStyleCache_ = {}; this.lonLabelStyleBase_ = new Style({
/**
* @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({
text: options.lonLabelStyle !== undefined ? options.lonLabelStyle.clone() : text: options.lonLabelStyle !== undefined ? options.lonLabelStyle.clone() :
new Text({ new Text({
font: '12px Calibri,sans-serif', 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 * @private
* @param {import("../Feature").default} feature Feature * @param {import("../Feature").default} feature Feature
* @return {Style} style * @return {Style} style
*/ */
this.latLabelStyle_ = function(feature) { this.lonLabelStyle_ = function(feature) {
const label = feature.get('graticule_label'); const label = feature.get('graticule_label');
if (!this.latLabelStyleCache_[label]) { this.lonLabelStyleBase_.getText().setText(label);
this.latLabelStyleCache_[label] = new Style({ return this.lonLabelStyleBase_;
}.bind(this);
/**
* @type {Style}
* @private
*/
this.latLabelStyleBase_ = new Style({
text: options.latLabelStyle !== undefined ? options.latLabelStyle.clone() : text: options.latLabelStyle !== undefined ? options.latLabelStyle.clone() :
new Text({ new Text({
font: '12px Calibri,sans-serif', 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); }.bind(this);
this.meridiansLabels_ = []; this.meridiansLabels_ = [];