Use 'text' instead of 'name' for the label text

This commit is contained in:
ahocevar
2013-06-19 22:10:44 +02:00
parent 7353e05a90
commit cb9f4972df
5 changed files with 15 additions and 15 deletions

View File

@@ -56,7 +56,7 @@ var style = new ol.style.Style({rules: [
}), }),
new ol.style.Text({ new ol.style.Text({
color: '#bada55', color: '#bada55',
name: new ol.Expression('label'), text: new ol.Expression('label'),
fontFamily: 'Calibri,sans-serif', fontFamily: 'Calibri,sans-serif',
fontSize: 14 fontSize: 14
}) })

View File

@@ -578,7 +578,7 @@
* @property {string|ol.Expression|undefined} color Color. * @property {string|ol.Expression|undefined} color Color.
* @property {string|ol.Expression|undefined} fontFamily Font family. * @property {string|ol.Expression|undefined} fontFamily Font family.
* @property {number|ol.Expression|undefined} fontSize Font size in pixels. * @property {number|ol.Expression|undefined} fontSize Font size in pixels.
* @property {string|ol.Expression} name Name (i.e. text content) of the label. * @property {string|ol.Expression} text Text for the label.
* @property {number|ol.Expression|undefined} opacity Opacity (0-1). * @property {number|ol.Expression|undefined} opacity Opacity (0-1).
*/ */

View File

@@ -318,7 +318,7 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral =
item = featuresBySymbolizer[uniqueLiterals[key]]; item = featuresBySymbolizer[uniqueLiterals[key]];
item[0].push(feature); item[0].push(feature);
if (literal instanceof ol.style.TextLiteral) { if (literal instanceof ol.style.TextLiteral) {
item[2].push(literals[j].name); item[2].push(literals[j].text);
} }
} }
} }

View File

@@ -266,11 +266,11 @@ ol.renderer.canvas.VectorRenderer.prototype.renderPointFeatures_ =
/** /**
* @param {Array.<ol.Feature>} features Array of features. * @param {Array.<ol.Feature>} features Array of features.
* @param {ol.style.TextLiteral} text Text symbolizer. * @param {ol.style.TextLiteral} text Text symbolizer.
* @param {Array} names Label text for each feature. * @param {Array} texts Label text for each feature.
* @private * @private
*/ */
ol.renderer.canvas.VectorRenderer.prototype.renderLabels_ = ol.renderer.canvas.VectorRenderer.prototype.renderLabels_ =
function(features, text, names) { function(features, text, texts) {
var context = this.context_, var context = this.context_,
fontArray = [], fontArray = [],
color = text.color, color = text.color,
@@ -298,7 +298,7 @@ ol.renderer.canvas.VectorRenderer.prototype.renderLabels_ =
for (var j = 0, jj = vecs.length; j < jj; ++j) { for (var j = 0, jj = vecs.length; j < jj; ++j) {
vec = vecs[j]; vec = vecs[j];
goog.vec.Mat4.multVec3(this.transform_, vec, vec); goog.vec.Mat4.multVec3(this.transform_, vec, vec);
context.fillText(names[i], vec[0], vec[1]); context.fillText(texts[i], vec[0], vec[1]);
} }
} }

View File

@@ -12,7 +12,7 @@ goog.require('ol.style.SymbolizerLiteral');
* @typedef {{color: (string|undefined), * @typedef {{color: (string|undefined),
* fontFamily: (string|undefined), * fontFamily: (string|undefined),
* fontSize: number, * fontSize: number,
* name: string, * text: string,
* opacity: number}} * opacity: number}}
*/ */
ol.style.TextLiteralOptions; ol.style.TextLiteralOptions;
@@ -43,9 +43,9 @@ ol.style.TextLiteral = function(options) {
/** @type {number} */ /** @type {number} */
this.fontSize = options.fontSize; this.fontSize = options.fontSize;
goog.asserts.assertString(options.name, 'name must be a string'); goog.asserts.assertString(options.text, 'text must be a string');
/** @type {string} */ /** @type {string} */
this.name = options.name; this.text = options.text;
goog.asserts.assertNumber(options.opacity, 'opacity must be a number'); goog.asserts.assertNumber(options.opacity, 'opacity must be a number');
/** @type {number} */ /** @type {number} */
@@ -105,8 +105,8 @@ ol.style.Text = function(options) {
* @type {ol.Expression} * @type {ol.Expression}
* @private * @private
*/ */
this.name_ = (options.name instanceof ol.Expression) ? this.text_ = (options.text instanceof ol.Expression) ?
options.name : new ol.ExpressionLiteral(options.name); options.text : new ol.ExpressionLiteral(options.text);
/** /**
* @type {ol.Expression} * @type {ol.Expression}
@@ -145,8 +145,8 @@ ol.style.Text.prototype.createLiteral = function(opt_feature) {
var fontSize = this.fontSize_.evaluate(feature, attrs); var fontSize = this.fontSize_.evaluate(feature, attrs);
goog.asserts.assertNumber(fontSize, 'fontSize must be a number'); goog.asserts.assertNumber(fontSize, 'fontSize must be a number');
var name = this.name_.evaluate(feature, attrs); var text = this.text_.evaluate(feature, attrs);
goog.asserts.assertString(name, 'name must be a string'); goog.asserts.assertString(text, 'text must be a string');
var opacity = this.opacity_.evaluate(feature, attrs); var opacity = this.opacity_.evaluate(feature, attrs);
goog.asserts.assertNumber(opacity, 'opacity must be a number'); goog.asserts.assertNumber(opacity, 'opacity must be a number');
@@ -155,7 +155,7 @@ ol.style.Text.prototype.createLiteral = function(opt_feature) {
color: color, color: color,
fontFamily: fontFamily, fontFamily: fontFamily,
fontSize: fontSize, fontSize: fontSize,
name: name, text: text,
opacity: opacity opacity: opacity
}); });
}; };
@@ -166,6 +166,6 @@ ol.style.Text.prototype.createLiteral = function(opt_feature) {
*/ */
ol.style.TextDefaults = new ol.style.TextLiteral({ ol.style.TextDefaults = new ol.style.TextLiteral({
fontSize: 10, fontSize: 10,
name: '', text: '',
opacity: 1 opacity: 1
}); });