We are guarnteed that all TextLiteral properties are defined (see #770)
Instead of using the browser defaults, we use `ol.style.TextDefaults`.
This commit is contained in:
@@ -272,22 +272,12 @@ ol.renderer.canvas.VectorRenderer.prototype.renderPointFeatures_ =
|
|||||||
ol.renderer.canvas.VectorRenderer.prototype.renderText_ =
|
ol.renderer.canvas.VectorRenderer.prototype.renderText_ =
|
||||||
function(features, text, texts) {
|
function(features, text, texts) {
|
||||||
var context = this.context_,
|
var context = this.context_,
|
||||||
fontArray = [],
|
|
||||||
color = text.color,
|
|
||||||
vecs, vec;
|
vecs, vec;
|
||||||
|
|
||||||
if (color) {
|
if (context.fillStyle !== text.color) {
|
||||||
context.fillStyle = color;
|
context.fillStyle = text.color;
|
||||||
}
|
|
||||||
if (goog.isDef(text.fontSize)) {
|
|
||||||
fontArray.push(text.fontSize + 'px');
|
|
||||||
}
|
|
||||||
if (goog.isDef(text.fontFamily)) {
|
|
||||||
fontArray.push(text.fontFamily);
|
|
||||||
}
|
|
||||||
if (fontArray.length) {
|
|
||||||
context.font = fontArray.join(' ');
|
|
||||||
}
|
}
|
||||||
|
context.font = text.fontSize + 'px ' + text.fontFamily;
|
||||||
context.globalAlpha = text.opacity;
|
context.globalAlpha = text.opacity;
|
||||||
|
|
||||||
// TODO: make alignments configurable
|
// TODO: make alignments configurable
|
||||||
|
|||||||
@@ -26,18 +26,13 @@ ol.style.TextLiteralOptions;
|
|||||||
*/
|
*/
|
||||||
ol.style.TextLiteral = function(options) {
|
ol.style.TextLiteral = function(options) {
|
||||||
|
|
||||||
|
goog.asserts.assertString(options.color, 'color must be a string');
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
this.color = options.color;
|
this.color = options.color;
|
||||||
if (goog.isDef(options.color)) {
|
|
||||||
goog.asserts.assertString(options.color, 'color must be a string');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
goog.asserts.assertString(options.fontFamily, 'fontFamily must be a string');
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
this.fontFamily = options.fontFamily;
|
this.fontFamily = options.fontFamily;
|
||||||
if (goog.isDef(options.fontFamily)) {
|
|
||||||
goog.asserts.assertString(options.fontFamily,
|
|
||||||
'fontFamily must be a string');
|
|
||||||
}
|
|
||||||
|
|
||||||
goog.asserts.assertNumber(options.fontSize, 'fontSize must be a number');
|
goog.asserts.assertNumber(options.fontSize, 'fontSize must be a number');
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
|
|||||||
Reference in New Issue
Block a user