Merge pull request #4111 from marcjansen/text-default-fill

Use a blackish default for filling texts
This commit is contained in:
Marc Jansen
2015-09-18 07:28:17 +09:00
3 changed files with 50 additions and 5 deletions
+4 -4
View File
@@ -4241,7 +4241,7 @@ olx.source.ImageMapGuideOptions.prototype.projection;
/** /**
* Ratio. `1` means image requests are the size of the map viewport, `2` means * Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or * twice the width and height of the map viewport, and so on. Must be `1` or
* higher. Default is `1`. * higher. Default is `1`.
* @type {number|undefined} * @type {number|undefined}
* @api stable * @api stable
@@ -4524,7 +4524,7 @@ olx.source.ImageVectorOptions.prototype.projection;
/** /**
* Ratio. 1 means canvases are the size of the map viewport, 2 means twice the * Ratio. 1 means canvases are the size of the map viewport, 2 means twice the
* width and height of the map viewport, and so on. Must be `1` or higher. * width and height of the map viewport, and so on. Must be `1` or higher.
* Default is `1.5`. * Default is `1.5`.
* @type {number|undefined} * @type {number|undefined}
* @api * @api
@@ -4708,7 +4708,7 @@ olx.source.ImageWMSOptions.prototype.projection;
/** /**
* Ratio. `1` means image requests are the size of the map viewport, `2` means * Ratio. `1` means image requests are the size of the map viewport, `2` means
* twice the width and height of the map viewport, and so on. Must be `1` or * twice the width and height of the map viewport, and so on. Must be `1` or
* higher. Default is `1.5`. * higher. Default is `1.5`.
* @type {number|undefined} * @type {number|undefined}
* @api stable * @api stable
@@ -6216,7 +6216,7 @@ olx.style.TextOptions.prototype.textBaseline;
/** /**
* Fill style. * Fill style. If none is provided, we'll use a dark fill-style (#333).
* @type {ol.style.Fill|undefined} * @type {ol.style.Fill|undefined}
* @api * @api
*/ */
+15 -1
View File
@@ -1,6 +1,9 @@
goog.provide('ol.style.Text'); goog.provide('ol.style.Text');
goog.require('ol.style.Fill');
/** /**
* @classdesc * @classdesc
@@ -54,7 +57,8 @@ ol.style.Text = function(opt_options) {
* @private * @private
* @type {ol.style.Fill} * @type {ol.style.Fill}
*/ */
this.fill_ = goog.isDef(options.fill) ? options.fill : null; this.fill_ = goog.isDef(options.fill) ? options.fill :
new ol.style.Fill({color: ol.style.Text.DEFAULT_FILL_COLOR_});
/** /**
* @private * @private
@@ -76,6 +80,16 @@ ol.style.Text = function(opt_options) {
}; };
/**
* The default fill color to use if no fill was set at construction time; a
* blackish `#333`.
*
* @const {string}
* @private
*/
ol.style.Text.DEFAULT_FILL_COLOR_ = '#333';
/** /**
* Get the font name. * Get the font name.
* @return {string|undefined} Font. * @return {string|undefined} Font.
+31
View File
@@ -0,0 +1,31 @@
goog.provide('ol.test.style.Text');
describe('ol.style.Text', function() {
describe('#constructor', function() {
it('uses a default fill style if none passed', function() {
var style = new ol.style.Text();
expect(style.getFill().getColor()).to.be('#333');
});
it('uses a provided fill style if one passed', function() {
var style = new ol.style.Text({
fill: new ol.style.Fill({color: '#123456'})
});
expect(style.getFill().getColor()).to.be('#123456');
});
it('can always be resetted to no color', function() {
var style = new ol.style.Text();
style.getFill().setColor();
expect(style.getFill().getColor()).to.be(undefined);
});
});
});
goog.require('ol.style.Fill');
goog.require('ol.style.Text');