Use fillColor and strokeColor instead of fillStyle and strokeStyle
The color names are more intuitive. And if we want to support pattern strokes or fills, we'll need additional proerties to represent other pattern properties.
This commit is contained in:
@@ -151,13 +151,13 @@
|
|||||||
@exportObjectLiteralProperty ol.style.IconOptions.rotation number|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.IconOptions.rotation number|ol.Expression|undefined
|
||||||
|
|
||||||
@exportObjectLiteral ol.style.LineOptions
|
@exportObjectLiteral ol.style.LineOptions
|
||||||
@exportObjectLiteralProperty ol.style.LineOptions.strokeStyle string|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.LineOptions.strokeColor string|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.LineOptions.strokeWidth number|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.LineOptions.strokeWidth number|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.LineOptions.opacity number|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.LineOptions.opacity number|ol.Expression|undefined
|
||||||
|
|
||||||
@exportObjectLiteral ol.style.PolygonOptions
|
@exportObjectLiteral ol.style.PolygonOptions
|
||||||
@exportObjectLiteralProperty ol.style.PolygonOptions.fillStyle string|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.PolygonOptions.fillColor string|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.PolygonOptions.strokeStyle string|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.PolygonOptions.strokeColor string|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.PolygonOptions.strokeWidth number|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.PolygonOptions.strokeWidth number|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.PolygonOptions.opacity number|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.PolygonOptions.opacity number|ol.Expression|undefined
|
||||||
|
|
||||||
@@ -168,8 +168,8 @@
|
|||||||
@exportObjectLiteral ol.style.ShapeOptions
|
@exportObjectLiteral ol.style.ShapeOptions
|
||||||
@exportObjectLiteralProperty ol.style.ShapeOptions.type ol.style.ShapeType|undefined
|
@exportObjectLiteralProperty ol.style.ShapeOptions.type ol.style.ShapeType|undefined
|
||||||
@exportObjectLiteralProperty ol.style.ShapeOptions.size number|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.ShapeOptions.size number|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.ShapeOptions.fillStyle string|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.ShapeOptions.fillColor string|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.ShapeOptions.strokeStyle string|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.ShapeOptions.strokeColor string|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.ShapeOptions.strokeWidth number|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.ShapeOptions.strokeWidth number|ol.Expression|undefined
|
||||||
@exportObjectLiteralProperty ol.style.ShapeOptions.opacity number|ol.Expression|undefined
|
@exportObjectLiteralProperty ol.style.ShapeOptions.opacity number|ol.Expression|undefined
|
||||||
|
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ ol.renderer.canvas.Renderer.prototype.renderLineStringFeatures_ =
|
|||||||
i, ii, geometry, components, j, jj, line, dim, k, kk, x, y;
|
i, ii, geometry, components, j, jj, line, dim, k, kk, x, y;
|
||||||
|
|
||||||
context.globalAlpha = symbolizer.opacity;
|
context.globalAlpha = symbolizer.opacity;
|
||||||
context.strokeStyle = symbolizer.strokeStyle;
|
context.strokeStyle = symbolizer.strokeColor;
|
||||||
context.lineWidth = symbolizer.strokeWidth * this.inverseScale_;
|
context.lineWidth = symbolizer.strokeWidth * this.inverseScale_;
|
||||||
context.lineCap = 'round'; // TODO: accept this as a symbolizer property
|
context.lineCap = 'round'; // TODO: accept this as a symbolizer property
|
||||||
context.lineJoin = 'round'; // TODO: accept this as a symbolizer property
|
context.lineJoin = 'round'; // TODO: accept this as a symbolizer property
|
||||||
@@ -232,20 +232,20 @@ ol.renderer.canvas.Renderer.prototype.renderPointFeatures_ =
|
|||||||
ol.renderer.canvas.Renderer.prototype.renderPolygonFeatures_ =
|
ol.renderer.canvas.Renderer.prototype.renderPolygonFeatures_ =
|
||||||
function(features, symbolizer) {
|
function(features, symbolizer) {
|
||||||
var context = this.context_,
|
var context = this.context_,
|
||||||
strokeStyle = symbolizer.strokeStyle,
|
strokeColor = symbolizer.strokeColor,
|
||||||
fillStyle = symbolizer.fillStyle,
|
fillColor = symbolizer.fillColor,
|
||||||
i, ii, geometry, components, j, jj, poly,
|
i, ii, geometry, components, j, jj, poly,
|
||||||
rings, numRings, ring, dim, k, kk, x, y;
|
rings, numRings, ring, dim, k, kk, x, y;
|
||||||
|
|
||||||
context.globalAlpha = symbolizer.opacity;
|
context.globalAlpha = symbolizer.opacity;
|
||||||
if (strokeStyle) {
|
if (strokeColor) {
|
||||||
context.strokeStyle = symbolizer.strokeStyle;
|
context.strokeStyle = symbolizer.strokeColor;
|
||||||
context.lineWidth = symbolizer.strokeWidth * this.inverseScale_;
|
context.lineWidth = symbolizer.strokeWidth * this.inverseScale_;
|
||||||
context.lineCap = 'round'; // TODO: accept this as a symbolizer property
|
context.lineCap = 'round'; // TODO: accept this as a symbolizer property
|
||||||
context.lineJoin = 'round'; // TODO: accept this as a symbolizer property
|
context.lineJoin = 'round'; // TODO: accept this as a symbolizer property
|
||||||
}
|
}
|
||||||
if (fillStyle) {
|
if (fillColor) {
|
||||||
context.fillStyle = fillStyle;
|
context.fillStyle = fillColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -282,7 +282,7 @@ ol.renderer.canvas.Renderer.prototype.renderPolygonFeatures_ =
|
|||||||
context.lineTo(x, y);
|
context.lineTo(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fillStyle && strokeStyle) {
|
if (fillColor && strokeColor) {
|
||||||
// scenario 3 - fill and stroke each time
|
// scenario 3 - fill and stroke each time
|
||||||
context.fill();
|
context.fill();
|
||||||
context.stroke();
|
context.stroke();
|
||||||
@@ -293,8 +293,8 @@ ol.renderer.canvas.Renderer.prototype.renderPolygonFeatures_ =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(fillStyle && strokeStyle)) {
|
if (!(fillColor && strokeColor)) {
|
||||||
if (fillStyle) {
|
if (fillColor) {
|
||||||
// scenario 2 - fill all at once
|
// scenario 2 - fill all at once
|
||||||
context.fill();
|
context.fill();
|
||||||
} else {
|
} else {
|
||||||
@@ -318,8 +318,8 @@ ol.renderer.canvas.Renderer.renderCircle_ = function(circle) {
|
|||||||
(goog.dom.createElement(goog.dom.TagName.CANVAS)),
|
(goog.dom.createElement(goog.dom.TagName.CANVAS)),
|
||||||
context = /** @type {CanvasRenderingContext2D} */
|
context = /** @type {CanvasRenderingContext2D} */
|
||||||
(canvas.getContext('2d')),
|
(canvas.getContext('2d')),
|
||||||
fillStyle = circle.fillStyle,
|
fillColor = circle.fillColor,
|
||||||
strokeStyle = circle.strokeStyle,
|
strokeColor = circle.strokeColor,
|
||||||
twoPi = Math.PI * 2;
|
twoPi = Math.PI * 2;
|
||||||
|
|
||||||
canvas.height = size;
|
canvas.height = size;
|
||||||
@@ -327,12 +327,12 @@ ol.renderer.canvas.Renderer.renderCircle_ = function(circle) {
|
|||||||
|
|
||||||
context.globalAlpha = circle.opacity;
|
context.globalAlpha = circle.opacity;
|
||||||
|
|
||||||
if (fillStyle) {
|
if (fillColor) {
|
||||||
context.fillStyle = fillStyle;
|
context.fillStyle = fillColor;
|
||||||
}
|
}
|
||||||
if (strokeStyle) {
|
if (strokeColor) {
|
||||||
context.lineWidth = strokeWidth;
|
context.lineWidth = strokeWidth;
|
||||||
context.strokeStyle = strokeStyle;
|
context.strokeStyle = strokeColor;
|
||||||
context.lineCap = 'round'; // TODO: accept this as a symbolizer property
|
context.lineCap = 'round'; // TODO: accept this as a symbolizer property
|
||||||
context.lineJoin = 'round'; // TODO: accept this as a symbolizer property
|
context.lineJoin = 'round'; // TODO: accept this as a symbolizer property
|
||||||
}
|
}
|
||||||
@@ -340,10 +340,10 @@ ol.renderer.canvas.Renderer.renderCircle_ = function(circle) {
|
|||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.arc(mid, mid, circle.size / 2, 0, twoPi, true);
|
context.arc(mid, mid, circle.size / 2, 0, twoPi, true);
|
||||||
|
|
||||||
if (fillStyle) {
|
if (fillColor) {
|
||||||
context.fill();
|
context.fill();
|
||||||
}
|
}
|
||||||
if (strokeStyle) {
|
if (strokeColor) {
|
||||||
context.stroke();
|
context.stroke();
|
||||||
}
|
}
|
||||||
return canvas;
|
return canvas;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ goog.require('ol.style.SymbolizerLiteral');
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{strokeStyle: (string),
|
* @typedef {{strokeColor: (string),
|
||||||
* strokeWidth: (number),
|
* strokeWidth: (number),
|
||||||
* opacity: (number)}}
|
* opacity: (number)}}
|
||||||
*/
|
*/
|
||||||
@@ -24,9 +24,9 @@ ol.style.LineLiteralOptions;
|
|||||||
ol.style.LineLiteral = function(config) {
|
ol.style.LineLiteral = function(config) {
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
|
|
||||||
goog.asserts.assertString(config.strokeStyle, 'strokeStyle must be a string');
|
goog.asserts.assertString(config.strokeColor, 'strokeColor must be a string');
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
this.strokeStyle = config.strokeStyle;
|
this.strokeColor = config.strokeColor;
|
||||||
|
|
||||||
goog.asserts.assertNumber(config.strokeWidth, 'strokeWidth must be a number');
|
goog.asserts.assertNumber(config.strokeWidth, 'strokeWidth must be a number');
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
@@ -44,7 +44,7 @@ goog.inherits(ol.style.LineLiteral, ol.style.SymbolizerLiteral);
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.style.LineLiteral.prototype.equals = function(lineLiteral) {
|
ol.style.LineLiteral.prototype.equals = function(lineLiteral) {
|
||||||
return this.strokeStyle == lineLiteral.strokeStyle &&
|
return this.strokeColor == lineLiteral.strokeColor &&
|
||||||
this.strokeWidth == lineLiteral.strokeWidth &&
|
this.strokeWidth == lineLiteral.strokeWidth &&
|
||||||
this.opacity == lineLiteral.opacity;
|
this.opacity == lineLiteral.opacity;
|
||||||
};
|
};
|
||||||
@@ -63,10 +63,10 @@ ol.style.Line = function(options) {
|
|||||||
* @type {ol.Expression}
|
* @type {ol.Expression}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.strokeStyle_ = !goog.isDef(options.strokeStyle) ?
|
this.strokeColor_ = !goog.isDef(options.strokeColor) ?
|
||||||
new ol.ExpressionLiteral(ol.style.LineDefaults.strokeStyle) :
|
new ol.ExpressionLiteral(ol.style.LineDefaults.strokeColor) :
|
||||||
(options.strokeStyle instanceof ol.Expression) ?
|
(options.strokeColor instanceof ol.Expression) ?
|
||||||
options.strokeStyle : new ol.ExpressionLiteral(options.strokeStyle);
|
options.strokeColor : new ol.ExpressionLiteral(options.strokeColor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Expression}
|
* @type {ol.Expression}
|
||||||
@@ -101,8 +101,8 @@ ol.style.Line.prototype.createLiteral = function(opt_feature) {
|
|||||||
attrs = feature.getAttributes();
|
attrs = feature.getAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
var strokeStyle = this.strokeStyle_.evaluate(feature, attrs);
|
var strokeColor = this.strokeColor_.evaluate(feature, attrs);
|
||||||
goog.asserts.assertString(strokeStyle, 'strokeStyle must be a string');
|
goog.asserts.assertString(strokeColor, 'strokeColor must be a string');
|
||||||
|
|
||||||
var strokeWidth = this.strokeWidth_.evaluate(feature, attrs);
|
var strokeWidth = this.strokeWidth_.evaluate(feature, attrs);
|
||||||
goog.asserts.assertNumber(strokeWidth, 'strokeWidth must be a number');
|
goog.asserts.assertNumber(strokeWidth, 'strokeWidth must be a number');
|
||||||
@@ -111,7 +111,7 @@ ol.style.Line.prototype.createLiteral = function(opt_feature) {
|
|||||||
goog.asserts.assertNumber(opacity, 'opacity must be a number');
|
goog.asserts.assertNumber(opacity, 'opacity must be a number');
|
||||||
|
|
||||||
return new ol.style.LineLiteral({
|
return new ol.style.LineLiteral({
|
||||||
strokeStyle: strokeStyle,
|
strokeColor: strokeColor,
|
||||||
strokeWidth: strokeWidth,
|
strokeWidth: strokeWidth,
|
||||||
opacity: opacity
|
opacity: opacity
|
||||||
});
|
});
|
||||||
@@ -122,7 +122,7 @@ ol.style.Line.prototype.createLiteral = function(opt_feature) {
|
|||||||
* @type {ol.style.LineLiteral}
|
* @type {ol.style.LineLiteral}
|
||||||
*/
|
*/
|
||||||
ol.style.LineDefaults = new ol.style.LineLiteral({
|
ol.style.LineDefaults = new ol.style.LineLiteral({
|
||||||
strokeStyle: '#696969',
|
strokeColor: '#696969',
|
||||||
strokeWidth: 1.5,
|
strokeWidth: 1.5,
|
||||||
opacity: 0.75
|
opacity: 0.75
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ goog.require('ol.style.SymbolizerLiteral');
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{fillStyle: (string|undefined),
|
* @typedef {{fillColor: (string|undefined),
|
||||||
* strokeStyle: (string|undefined),
|
* strokeColor: (string|undefined),
|
||||||
* strokeWidth: (number|undefined),
|
* strokeWidth: (number|undefined),
|
||||||
* opacity: (number)}}
|
* opacity: (number)}}
|
||||||
*/
|
*/
|
||||||
@@ -26,16 +26,16 @@ ol.style.PolygonLiteral = function(config) {
|
|||||||
goog.base(this);
|
goog.base(this);
|
||||||
|
|
||||||
/** @type {string|undefined} */
|
/** @type {string|undefined} */
|
||||||
this.fillStyle = config.fillStyle;
|
this.fillColor = config.fillColor;
|
||||||
if (goog.isDef(config.fillStyle)) {
|
if (goog.isDef(config.fillColor)) {
|
||||||
goog.asserts.assertString(config.fillStyle, 'fillStyle must be a string');
|
goog.asserts.assertString(config.fillColor, 'fillColor must be a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {string|undefined} */
|
/** @type {string|undefined} */
|
||||||
this.strokeStyle = config.strokeStyle;
|
this.strokeColor = config.strokeColor;
|
||||||
if (goog.isDef(this.strokeStyle)) {
|
if (goog.isDef(this.strokeColor)) {
|
||||||
goog.asserts.assertString(
|
goog.asserts.assertString(
|
||||||
this.strokeStyle, 'strokeStyle must be a string');
|
this.strokeColor, 'strokeColor must be a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {number|undefined} */
|
/** @type {number|undefined} */
|
||||||
@@ -46,9 +46,9 @@ ol.style.PolygonLiteral = function(config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
goog.isDef(this.fillStyle) ||
|
goog.isDef(this.fillColor) ||
|
||||||
(goog.isDef(this.strokeStyle) && goog.isDef(this.strokeWidth)),
|
(goog.isDef(this.strokeColor) && goog.isDef(this.strokeWidth)),
|
||||||
'Either fillStyle or strokeStyle and strokeWidth must be set');
|
'Either fillColor or strokeColor and strokeWidth must be set');
|
||||||
|
|
||||||
goog.asserts.assertNumber(config.opacity, 'opacity must be a number');
|
goog.asserts.assertNumber(config.opacity, 'opacity must be a number');
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
@@ -62,8 +62,8 @@ goog.inherits(ol.style.PolygonLiteral, ol.style.SymbolizerLiteral);
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.style.PolygonLiteral.prototype.equals = function(polygonLiteral) {
|
ol.style.PolygonLiteral.prototype.equals = function(polygonLiteral) {
|
||||||
return this.fillStyle == polygonLiteral.fillStyle &&
|
return this.fillColor == polygonLiteral.fillColor &&
|
||||||
this.strokeStyle == polygonLiteral.strokeStyle &&
|
this.strokeColor == polygonLiteral.strokeColor &&
|
||||||
this.strokeWidth == polygonLiteral.strokeWidth &&
|
this.strokeWidth == polygonLiteral.strokeWidth &&
|
||||||
this.opacity == polygonLiteral.opacity;
|
this.opacity == polygonLiteral.opacity;
|
||||||
};
|
};
|
||||||
@@ -82,22 +82,22 @@ ol.style.Polygon = function(options) {
|
|||||||
* @type {ol.Expression}
|
* @type {ol.Expression}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.fillStyle_ = !goog.isDefAndNotNull(options.fillStyle) ?
|
this.fillColor_ = !goog.isDefAndNotNull(options.fillColor) ?
|
||||||
null :
|
null :
|
||||||
(options.fillStyle instanceof ol.Expression) ?
|
(options.fillColor instanceof ol.Expression) ?
|
||||||
options.fillStyle : new ol.ExpressionLiteral(options.fillStyle);
|
options.fillColor : new ol.ExpressionLiteral(options.fillColor);
|
||||||
|
|
||||||
// stroke handling - if any stroke property is supplied, use defaults
|
// stroke handling - if any stroke property is supplied, use defaults
|
||||||
var strokeStyle = null,
|
var strokeColor = null,
|
||||||
strokeWidth = null;
|
strokeWidth = null;
|
||||||
|
|
||||||
if (goog.isDefAndNotNull(options.strokeStyle) ||
|
if (goog.isDefAndNotNull(options.strokeColor) ||
|
||||||
goog.isDefAndNotNull(options.strokeWidth)) {
|
goog.isDefAndNotNull(options.strokeWidth)) {
|
||||||
|
|
||||||
strokeStyle = !goog.isDefAndNotNull(options.strokeStyle) ?
|
strokeColor = !goog.isDefAndNotNull(options.strokeColor) ?
|
||||||
new ol.ExpressionLiteral(ol.style.PolygonDefaults.strokeStyle) :
|
new ol.ExpressionLiteral(ol.style.PolygonDefaults.strokeColor) :
|
||||||
(options.strokeStyle instanceof ol.Expression) ?
|
(options.strokeColor instanceof ol.Expression) ?
|
||||||
options.strokeStyle : new ol.ExpressionLiteral(options.strokeStyle);
|
options.strokeColor : new ol.ExpressionLiteral(options.strokeColor);
|
||||||
|
|
||||||
strokeWidth = !goog.isDef(options.strokeWidth) ?
|
strokeWidth = !goog.isDef(options.strokeWidth) ?
|
||||||
new ol.ExpressionLiteral(ol.style.PolygonDefaults.strokeWidth) :
|
new ol.ExpressionLiteral(ol.style.PolygonDefaults.strokeWidth) :
|
||||||
@@ -109,7 +109,7 @@ ol.style.Polygon = function(options) {
|
|||||||
* @type {ol.Expression}
|
* @type {ol.Expression}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.strokeStyle_ = strokeStyle;
|
this.strokeColor_ = strokeColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Expression}
|
* @type {ol.Expression}
|
||||||
@@ -118,8 +118,8 @@ ol.style.Polygon = function(options) {
|
|||||||
this.strokeWidth_ = strokeWidth;
|
this.strokeWidth_ = strokeWidth;
|
||||||
|
|
||||||
// one of stroke or fill can be null, both null is user error
|
// one of stroke or fill can be null, both null is user error
|
||||||
goog.asserts.assert(!goog.isNull(this.fillStyle_) ||
|
goog.asserts.assert(!goog.isNull(this.fillColor_) ||
|
||||||
!(goog.isNull(this.strokeStyle_) && goog.isNull(this.strokeWidth_)),
|
!(goog.isNull(this.strokeColor_) && goog.isNull(this.strokeWidth_)),
|
||||||
'Stroke or fill properties must be provided');
|
'Stroke or fill properties must be provided');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,15 +146,15 @@ ol.style.Polygon.prototype.createLiteral = function(opt_feature) {
|
|||||||
attrs = feature.getAttributes();
|
attrs = feature.getAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
var fillStyle = goog.isNull(this.fillStyle_) ?
|
var fillColor = goog.isNull(this.fillColor_) ?
|
||||||
undefined :
|
undefined :
|
||||||
/** @type {string} */ (this.fillStyle_.evaluate(feature, attrs));
|
/** @type {string} */ (this.fillColor_.evaluate(feature, attrs));
|
||||||
goog.asserts.assert(!goog.isDef(fillStyle) || goog.isString(fillStyle));
|
goog.asserts.assert(!goog.isDef(fillColor) || goog.isString(fillColor));
|
||||||
|
|
||||||
var strokeStyle = goog.isNull(this.strokeStyle_) ?
|
var strokeColor = goog.isNull(this.strokeColor_) ?
|
||||||
undefined :
|
undefined :
|
||||||
/** @type {string} */ (this.strokeStyle_.evaluate(feature, attrs));
|
/** @type {string} */ (this.strokeColor_.evaluate(feature, attrs));
|
||||||
goog.asserts.assert(!goog.isDef(strokeStyle) || goog.isString(strokeStyle));
|
goog.asserts.assert(!goog.isDef(strokeColor) || goog.isString(strokeColor));
|
||||||
|
|
||||||
var strokeWidth = goog.isNull(this.strokeWidth_) ?
|
var strokeWidth = goog.isNull(this.strokeWidth_) ?
|
||||||
undefined :
|
undefined :
|
||||||
@@ -162,16 +162,16 @@ ol.style.Polygon.prototype.createLiteral = function(opt_feature) {
|
|||||||
goog.asserts.assert(!goog.isDef(strokeWidth) || goog.isNumber(strokeWidth));
|
goog.asserts.assert(!goog.isDef(strokeWidth) || goog.isNumber(strokeWidth));
|
||||||
|
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
goog.isDef(fillStyle) ||
|
goog.isDef(fillColor) ||
|
||||||
(goog.isDef(strokeStyle) && goog.isDef(strokeWidth)),
|
(goog.isDef(strokeColor) && goog.isDef(strokeWidth)),
|
||||||
'either fill style or strokeStyle and strokeWidth must be defined');
|
'either fill style or strokeColor and strokeWidth must be defined');
|
||||||
|
|
||||||
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');
|
||||||
|
|
||||||
return new ol.style.PolygonLiteral({
|
return new ol.style.PolygonLiteral({
|
||||||
fillStyle: fillStyle,
|
fillColor: fillColor,
|
||||||
strokeStyle: strokeStyle,
|
strokeColor: strokeColor,
|
||||||
strokeWidth: strokeWidth,
|
strokeWidth: strokeWidth,
|
||||||
opacity: opacity
|
opacity: opacity
|
||||||
});
|
});
|
||||||
@@ -182,8 +182,8 @@ ol.style.Polygon.prototype.createLiteral = function(opt_feature) {
|
|||||||
* @type {ol.style.PolygonLiteral}
|
* @type {ol.style.PolygonLiteral}
|
||||||
*/
|
*/
|
||||||
ol.style.PolygonDefaults = new ol.style.PolygonLiteral({
|
ol.style.PolygonDefaults = new ol.style.PolygonLiteral({
|
||||||
fillStyle: '#ffffff',
|
fillColor: '#ffffff',
|
||||||
strokeStyle: '#696969',
|
strokeColor: '#696969',
|
||||||
strokeWidth: 1.5,
|
strokeWidth: 1.5,
|
||||||
opacity: 0.75
|
opacity: 0.75
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ ol.style.ShapeType = {
|
|||||||
/**
|
/**
|
||||||
* @typedef {{type: (ol.style.ShapeType),
|
* @typedef {{type: (ol.style.ShapeType),
|
||||||
* size: (number),
|
* size: (number),
|
||||||
* fillStyle: (string|undefined),
|
* fillColor: (string|undefined),
|
||||||
* strokeStyle: (string|undefined),
|
* strokeColor: (string|undefined),
|
||||||
* strokeWidth: (number|undefined),
|
* strokeWidth: (number|undefined),
|
||||||
* opacity: (number)}}
|
* opacity: (number)}}
|
||||||
*/
|
*/
|
||||||
@@ -44,16 +44,16 @@ ol.style.ShapeLiteral = function(config) {
|
|||||||
this.size = config.size;
|
this.size = config.size;
|
||||||
|
|
||||||
/** @type {string|undefined} */
|
/** @type {string|undefined} */
|
||||||
this.fillStyle = config.fillStyle;
|
this.fillColor = config.fillColor;
|
||||||
if (goog.isDef(config.fillStyle)) {
|
if (goog.isDef(config.fillColor)) {
|
||||||
goog.asserts.assertString(config.fillStyle, 'fillStyle must be a string');
|
goog.asserts.assertString(config.fillColor, 'fillColor must be a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {string|undefined} */
|
/** @type {string|undefined} */
|
||||||
this.strokeStyle = config.strokeStyle;
|
this.strokeColor = config.strokeColor;
|
||||||
if (goog.isDef(this.strokeStyle)) {
|
if (goog.isDef(this.strokeColor)) {
|
||||||
goog.asserts.assertString(
|
goog.asserts.assertString(
|
||||||
this.strokeStyle, 'strokeStyle must be a string');
|
this.strokeColor, 'strokeColor must be a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {number|undefined} */
|
/** @type {number|undefined} */
|
||||||
@@ -64,9 +64,9 @@ ol.style.ShapeLiteral = function(config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
goog.isDef(this.fillStyle) ||
|
goog.isDef(this.fillColor) ||
|
||||||
(goog.isDef(this.strokeStyle) && goog.isDef(this.strokeWidth)),
|
(goog.isDef(this.strokeColor) && goog.isDef(this.strokeWidth)),
|
||||||
'Either fillStyle or strokeStyle and strokeWidth must be set');
|
'Either fillColor or strokeColor and strokeWidth must be set');
|
||||||
|
|
||||||
goog.asserts.assertNumber(config.opacity, 'opacity must be a number');
|
goog.asserts.assertNumber(config.opacity, 'opacity must be a number');
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
@@ -82,8 +82,8 @@ goog.inherits(ol.style.ShapeLiteral, ol.style.PointLiteral);
|
|||||||
ol.style.ShapeLiteral.prototype.equals = function(shapeLiteral) {
|
ol.style.ShapeLiteral.prototype.equals = function(shapeLiteral) {
|
||||||
return this.type == shapeLiteral.type &&
|
return this.type == shapeLiteral.type &&
|
||||||
this.size == shapeLiteral.size &&
|
this.size == shapeLiteral.size &&
|
||||||
this.fillStyle == shapeLiteral.fillStyle &&
|
this.fillColor == shapeLiteral.fillColor &&
|
||||||
this.strokeStyle == shapeLiteral.strokeStyle &&
|
this.strokeColor == shapeLiteral.strokeColor &&
|
||||||
this.strokeWidth == shapeLiteral.strokeWidth &&
|
this.strokeWidth == shapeLiteral.strokeWidth &&
|
||||||
this.opacity == shapeLiteral.opacity;
|
this.opacity == shapeLiteral.opacity;
|
||||||
};
|
};
|
||||||
@@ -117,22 +117,22 @@ ol.style.Shape = function(options) {
|
|||||||
* @type {ol.Expression}
|
* @type {ol.Expression}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.fillStyle_ = !goog.isDefAndNotNull(options.fillStyle) ?
|
this.fillColor_ = !goog.isDefAndNotNull(options.fillColor) ?
|
||||||
null :
|
null :
|
||||||
(options.fillStyle instanceof ol.Expression) ?
|
(options.fillColor instanceof ol.Expression) ?
|
||||||
options.fillStyle : new ol.ExpressionLiteral(options.fillStyle);
|
options.fillColor : new ol.ExpressionLiteral(options.fillColor);
|
||||||
|
|
||||||
// stroke handling - if any stroke property is supplied, use defaults
|
// stroke handling - if any stroke property is supplied, use defaults
|
||||||
var strokeStyle = null,
|
var strokeColor = null,
|
||||||
strokeWidth = null;
|
strokeWidth = null;
|
||||||
|
|
||||||
if (goog.isDefAndNotNull(options.strokeStyle) ||
|
if (goog.isDefAndNotNull(options.strokeColor) ||
|
||||||
goog.isDefAndNotNull(options.strokeWidth)) {
|
goog.isDefAndNotNull(options.strokeWidth)) {
|
||||||
|
|
||||||
strokeStyle = !goog.isDefAndNotNull(options.strokeStyle) ?
|
strokeColor = !goog.isDefAndNotNull(options.strokeColor) ?
|
||||||
new ol.ExpressionLiteral(ol.style.ShapeDefaults.strokeStyle) :
|
new ol.ExpressionLiteral(ol.style.ShapeDefaults.strokeColor) :
|
||||||
(options.strokeStyle instanceof ol.Expression) ?
|
(options.strokeColor instanceof ol.Expression) ?
|
||||||
options.strokeStyle : new ol.ExpressionLiteral(options.strokeStyle);
|
options.strokeColor : new ol.ExpressionLiteral(options.strokeColor);
|
||||||
|
|
||||||
strokeWidth = !goog.isDef(options.strokeWidth) ?
|
strokeWidth = !goog.isDef(options.strokeWidth) ?
|
||||||
new ol.ExpressionLiteral(ol.style.ShapeDefaults.strokeWidth) :
|
new ol.ExpressionLiteral(ol.style.ShapeDefaults.strokeWidth) :
|
||||||
@@ -144,7 +144,7 @@ ol.style.Shape = function(options) {
|
|||||||
* @type {ol.Expression}
|
* @type {ol.Expression}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.strokeStyle_ = strokeStyle;
|
this.strokeColor_ = strokeColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Expression}
|
* @type {ol.Expression}
|
||||||
@@ -153,8 +153,8 @@ ol.style.Shape = function(options) {
|
|||||||
this.strokeWidth_ = strokeWidth;
|
this.strokeWidth_ = strokeWidth;
|
||||||
|
|
||||||
// one of stroke or fill can be null, both null is user error
|
// one of stroke or fill can be null, both null is user error
|
||||||
goog.asserts.assert(!goog.isNull(this.fillStyle_) ||
|
goog.asserts.assert(!goog.isNull(this.fillColor_) ||
|
||||||
!(goog.isNull(this.strokeStyle_) && goog.isNull(this.strokeWidth_)),
|
!(goog.isNull(this.strokeColor_) && goog.isNull(this.strokeWidth_)),
|
||||||
'Stroke or fill properties must be provided');
|
'Stroke or fill properties must be provided');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,22 +183,25 @@ ol.style.Shape.prototype.createLiteral = function(opt_feature) {
|
|||||||
var size = this.size_.evaluate(feature, attrs);
|
var size = this.size_.evaluate(feature, attrs);
|
||||||
goog.asserts.assertNumber(size, 'size must be a number');
|
goog.asserts.assertNumber(size, 'size must be a number');
|
||||||
|
|
||||||
var fillStyle = goog.isNull(this.fillStyle_) ?
|
var fillColor = goog.isNull(this.fillColor_) ?
|
||||||
undefined : this.fillStyle_.evaluate(feature, attrs);
|
undefined :
|
||||||
goog.asserts.assert(!goog.isDef(fillStyle) || goog.isString(fillStyle));
|
/** @type {string} */ (this.fillColor_.evaluate(feature, attrs));
|
||||||
|
goog.asserts.assert(!goog.isDef(fillColor) || goog.isString(fillColor));
|
||||||
|
|
||||||
var strokeStyle = goog.isNull(this.strokeStyle_) ?
|
var strokeColor = goog.isNull(this.strokeColor_) ?
|
||||||
undefined : this.strokeStyle_.evaluate(feature, attrs);
|
undefined :
|
||||||
goog.asserts.assert(!goog.isDef(strokeStyle) || goog.isString(strokeStyle));
|
/** @type {string} */ (this.strokeColor_.evaluate(feature, attrs));
|
||||||
|
goog.asserts.assert(!goog.isDef(strokeColor) || goog.isString(strokeColor));
|
||||||
|
|
||||||
var strokeWidth = goog.isNull(this.strokeWidth_) ?
|
var strokeWidth = goog.isNull(this.strokeWidth_) ?
|
||||||
undefined : this.strokeWidth_.evaluate(feature, attrs);
|
undefined :
|
||||||
|
/** @type {number} */ (this.strokeWidth_.evaluate(feature, attrs));
|
||||||
goog.asserts.assert(!goog.isDef(strokeWidth) || goog.isNumber(strokeWidth));
|
goog.asserts.assert(!goog.isDef(strokeWidth) || goog.isNumber(strokeWidth));
|
||||||
|
|
||||||
goog.asserts.assert(
|
goog.asserts.assert(
|
||||||
goog.isDef(fillStyle) ||
|
goog.isDef(fillColor) ||
|
||||||
(goog.isDef(strokeStyle) && goog.isDef(strokeWidth)),
|
(goog.isDef(strokeColor) && goog.isDef(strokeWidth)),
|
||||||
'either fill style or strokeStyle and strokeWidth must be defined');
|
'either fill style or strokeColor and strokeWidth must be defined');
|
||||||
|
|
||||||
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');
|
||||||
@@ -206,10 +209,9 @@ ol.style.Shape.prototype.createLiteral = function(opt_feature) {
|
|||||||
return new ol.style.ShapeLiteral({
|
return new ol.style.ShapeLiteral({
|
||||||
type: this.type_,
|
type: this.type_,
|
||||||
size: size,
|
size: size,
|
||||||
// TODO: check if typecast can be avoided here
|
fillColor: fillColor,
|
||||||
fillStyle: /** @type {string|undefined} */ (fillStyle),
|
strokeColor: strokeColor,
|
||||||
strokeStyle: /** @type {string|undefined} */ (strokeStyle),
|
strokeWidth: strokeWidth,
|
||||||
strokeWidth: /** @type {number|undefined} */ (strokeWidth),
|
|
||||||
opacity: opacity
|
opacity: opacity
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -221,8 +223,8 @@ ol.style.Shape.prototype.createLiteral = function(opt_feature) {
|
|||||||
ol.style.ShapeDefaults = new ol.style.ShapeLiteral({
|
ol.style.ShapeDefaults = new ol.style.ShapeLiteral({
|
||||||
type: ol.style.ShapeType.CIRCLE,
|
type: ol.style.ShapeType.CIRCLE,
|
||||||
size: 5,
|
size: 5,
|
||||||
fillStyle: '#ffffff',
|
fillColor: '#ffffff',
|
||||||
strokeStyle: '#696969',
|
strokeColor: '#696969',
|
||||||
strokeWidth: 1.5,
|
strokeWidth: 1.5,
|
||||||
opacity: 0.75
|
opacity: 0.75
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ describe('ol.layer.Vector', function() {
|
|||||||
symbolizers: [
|
symbolizers: [
|
||||||
new ol.style.Line({
|
new ol.style.Line({
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
strokeStyle: new ol.Expression('colorProperty'),
|
strokeColor: new ol.Expression('colorProperty'),
|
||||||
opacity: 1
|
opacity: 1
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
@@ -136,20 +136,20 @@ describe('ol.layer.Vector', function() {
|
|||||||
var groups = layer.groupFeaturesBySymbolizerLiteral(features);
|
var groups = layer.groupFeaturesBySymbolizerLiteral(features);
|
||||||
expect(groups.length).toBe(2);
|
expect(groups.length).toBe(2);
|
||||||
expect(groups[0][0].length).toBe(1);
|
expect(groups[0][0].length).toBe(1);
|
||||||
expect(groups[0][1].strokeStyle).toBe('#BADA55');
|
expect(groups[0][1].strokeColor).toBe('#BADA55');
|
||||||
expect(groups[1][0].length).toBe(2);
|
expect(groups[1][0].length).toBe(2);
|
||||||
expect(groups[1][1].strokeStyle).toBe('#013');
|
expect(groups[1][1].strokeColor).toBe('#013');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('groups equal symbolizers also when defined on features', function() {
|
it('groups equal symbolizers also when defined on features', function() {
|
||||||
var symbolizer = new ol.style.Line({
|
var symbolizer = new ol.style.Line({
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
strokeStyle: new ol.Expression('colorProperty'),
|
strokeColor: new ol.Expression('colorProperty'),
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
var anotherSymbolizer = new ol.style.Line({
|
var anotherSymbolizer = new ol.style.Line({
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
strokeStyle: '#BADA55',
|
strokeColor: '#BADA55',
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
var featureWithSymbolizers = new ol.Feature({
|
var featureWithSymbolizers = new ol.Feature({
|
||||||
|
|||||||
@@ -7,16 +7,16 @@ describe('ol.style.LineLiteral', function() {
|
|||||||
it('identifies equal literals', function() {
|
it('identifies equal literals', function() {
|
||||||
var literal = new ol.style.LineLiteral({
|
var literal = new ol.style.LineLiteral({
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
strokeStyle: '#BADA55',
|
strokeColor: '#BADA55',
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
var equalLiteral = new ol.style.LineLiteral({
|
var equalLiteral = new ol.style.LineLiteral({
|
||||||
strokeStyle: '#BADA55',
|
strokeColor: '#BADA55',
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
var differentLiteral = new ol.style.LineLiteral({
|
var differentLiteral = new ol.style.LineLiteral({
|
||||||
strokeStyle: '#013',
|
strokeColor: '#013',
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
@@ -34,7 +34,7 @@ describe('ol.style.Line', function() {
|
|||||||
|
|
||||||
it('accepts literal values', function() {
|
it('accepts literal values', function() {
|
||||||
var symbolizer = new ol.style.Line({
|
var symbolizer = new ol.style.Line({
|
||||||
strokeStyle: '#BADA55',
|
strokeColor: '#BADA55',
|
||||||
strokeWidth: 3
|
strokeWidth: 3
|
||||||
});
|
});
|
||||||
expect(symbolizer).toBeA(ol.style.Line);
|
expect(symbolizer).toBeA(ol.style.Line);
|
||||||
|
|||||||
@@ -7,19 +7,19 @@ describe('ol.style.PolygonLiteral', function() {
|
|||||||
it('identifies equal literals', function() {
|
it('identifies equal literals', function() {
|
||||||
var literal = new ol.style.PolygonLiteral({
|
var literal = new ol.style.PolygonLiteral({
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
strokeStyle: '#013',
|
strokeColor: '#013',
|
||||||
fillStyle: '#BADA55',
|
fillColor: '#BADA55',
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
var equalLiteral = new ol.style.PolygonLiteral({
|
var equalLiteral = new ol.style.PolygonLiteral({
|
||||||
fillStyle: '#BADA55',
|
fillColor: '#BADA55',
|
||||||
strokeStyle: '#013',
|
strokeColor: '#013',
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
var differentLiteral = new ol.style.PolygonLiteral({
|
var differentLiteral = new ol.style.PolygonLiteral({
|
||||||
fillStyle: '#013',
|
fillColor: '#013',
|
||||||
strokeStyle: '#013',
|
strokeColor: '#013',
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
@@ -37,7 +37,7 @@ describe('ol.style.Polygon', function() {
|
|||||||
|
|
||||||
it('accepts literal values', function() {
|
it('accepts literal values', function() {
|
||||||
var symbolizer = new ol.style.Polygon({
|
var symbolizer = new ol.style.Polygon({
|
||||||
fillStyle: '#BADA55',
|
fillColor: '#BADA55',
|
||||||
strokeWidth: 3
|
strokeWidth: 3
|
||||||
});
|
});
|
||||||
expect(symbolizer).toBeA(ol.style.Polygon);
|
expect(symbolizer).toBeA(ol.style.Polygon);
|
||||||
@@ -46,7 +46,7 @@ describe('ol.style.Polygon', function() {
|
|||||||
it('accepts expressions', function() {
|
it('accepts expressions', function() {
|
||||||
var symbolizer = new ol.style.Polygon({
|
var symbolizer = new ol.style.Polygon({
|
||||||
opacity: new ol.Expression('value / 100'),
|
opacity: new ol.Expression('value / 100'),
|
||||||
fillStyle: new ol.Expression('fillAttr')
|
fillColor: new ol.Expression('fillAttr')
|
||||||
});
|
});
|
||||||
expect(symbolizer).toBeA(ol.style.Polygon);
|
expect(symbolizer).toBeA(ol.style.Polygon);
|
||||||
});
|
});
|
||||||
@@ -58,7 +58,7 @@ describe('ol.style.Polygon', function() {
|
|||||||
it('evaluates expressions with the given feature', function() {
|
it('evaluates expressions with the given feature', function() {
|
||||||
var symbolizer = new ol.style.Polygon({
|
var symbolizer = new ol.style.Polygon({
|
||||||
opacity: new ol.Expression('value / 100'),
|
opacity: new ol.Expression('value / 100'),
|
||||||
fillStyle: new ol.Expression('fillAttr')
|
fillColor: new ol.Expression('fillAttr')
|
||||||
});
|
});
|
||||||
|
|
||||||
var feature = new ol.Feature({
|
var feature = new ol.Feature({
|
||||||
@@ -69,20 +69,20 @@ describe('ol.style.Polygon', function() {
|
|||||||
var literal = symbolizer.createLiteral(feature);
|
var literal = symbolizer.createLiteral(feature);
|
||||||
expect(literal).toBeA(ol.style.PolygonLiteral);
|
expect(literal).toBeA(ol.style.PolygonLiteral);
|
||||||
expect(literal.opacity).toBe(42 / 100);
|
expect(literal.opacity).toBe(42 / 100);
|
||||||
expect(literal.fillStyle).toBe('#ff0000');
|
expect(literal.fillColor).toBe('#ff0000');
|
||||||
expect(literal.strokeStyle).toBeUndefined();
|
expect(literal.strokeColor).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('applies default strokeWidth if only strokeStyle is given', function() {
|
it('applies default strokeWidth if only strokeColor is given', function() {
|
||||||
var symbolizer = new ol.style.Polygon({
|
var symbolizer = new ol.style.Polygon({
|
||||||
strokeStyle: '#ff0000'
|
strokeColor: '#ff0000'
|
||||||
});
|
});
|
||||||
|
|
||||||
var literal = symbolizer.createLiteral();
|
var literal = symbolizer.createLiteral();
|
||||||
expect(literal).toBeA(ol.style.PolygonLiteral);
|
expect(literal).toBeA(ol.style.PolygonLiteral);
|
||||||
expect(literal.strokeStyle).toBe('#ff0000');
|
expect(literal.strokeColor).toBe('#ff0000');
|
||||||
expect(literal.strokeWidth).toBe(1.5);
|
expect(literal.strokeWidth).toBe(1.5);
|
||||||
expect(literal.fillStyle).toBeUndefined();
|
expect(literal.fillColor).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,24 +8,24 @@ describe('ol.style.ShapeLiteral', function() {
|
|||||||
var literal = new ol.style.ShapeLiteral({
|
var literal = new ol.style.ShapeLiteral({
|
||||||
type: ol.style.ShapeType.CIRCLE,
|
type: ol.style.ShapeType.CIRCLE,
|
||||||
size: 4,
|
size: 4,
|
||||||
fillStyle: '#BADA55',
|
fillColor: '#BADA55',
|
||||||
strokeStyle: '#013',
|
strokeColor: '#013',
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
var equalLiteral = new ol.style.ShapeLiteral({
|
var equalLiteral = new ol.style.ShapeLiteral({
|
||||||
type: ol.style.ShapeType.CIRCLE,
|
type: ol.style.ShapeType.CIRCLE,
|
||||||
size: 4,
|
size: 4,
|
||||||
fillStyle: '#BADA55',
|
fillColor: '#BADA55',
|
||||||
strokeStyle: '#013',
|
strokeColor: '#013',
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
var differentLiteral = new ol.style.ShapeLiteral({
|
var differentLiteral = new ol.style.ShapeLiteral({
|
||||||
type: ol.style.ShapeType.CIRCLE,
|
type: ol.style.ShapeType.CIRCLE,
|
||||||
size: 4,
|
size: 4,
|
||||||
fillStyle: '#013',
|
fillColor: '#013',
|
||||||
strokeStyle: '#013',
|
strokeColor: '#013',
|
||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
@@ -44,7 +44,7 @@ describe('ol.style.Shape', function() {
|
|||||||
it('accepts literal values', function() {
|
it('accepts literal values', function() {
|
||||||
var symbolizer = new ol.style.Shape({
|
var symbolizer = new ol.style.Shape({
|
||||||
size: 4,
|
size: 4,
|
||||||
fillStyle: '#BADA55'
|
fillColor: '#BADA55'
|
||||||
});
|
});
|
||||||
expect(symbolizer).toBeA(ol.style.Shape);
|
expect(symbolizer).toBeA(ol.style.Shape);
|
||||||
});
|
});
|
||||||
@@ -52,7 +52,7 @@ describe('ol.style.Shape', function() {
|
|||||||
it('accepts expressions', function() {
|
it('accepts expressions', function() {
|
||||||
var symbolizer = new ol.style.Shape({
|
var symbolizer = new ol.style.Shape({
|
||||||
size: new ol.Expression('sizeAttr'),
|
size: new ol.Expression('sizeAttr'),
|
||||||
strokeStyle: new ol.Expression('color')
|
strokeColor: new ol.Expression('color')
|
||||||
});
|
});
|
||||||
expect(symbolizer).toBeA(ol.style.Shape);
|
expect(symbolizer).toBeA(ol.style.Shape);
|
||||||
});
|
});
|
||||||
@@ -65,7 +65,7 @@ describe('ol.style.Shape', function() {
|
|||||||
var symbolizer = new ol.style.Shape({
|
var symbolizer = new ol.style.Shape({
|
||||||
size: new ol.Expression('sizeAttr'),
|
size: new ol.Expression('sizeAttr'),
|
||||||
opacity: new ol.Expression('opacityAttr'),
|
opacity: new ol.Expression('opacityAttr'),
|
||||||
fillStyle: '#BADA55'
|
fillColor: '#BADA55'
|
||||||
});
|
});
|
||||||
|
|
||||||
var feature = new ol.Feature({
|
var feature = new ol.Feature({
|
||||||
@@ -83,8 +83,8 @@ describe('ol.style.Shape', function() {
|
|||||||
var symbolizer = new ol.style.Shape({
|
var symbolizer = new ol.style.Shape({
|
||||||
size: 10,
|
size: 10,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
fillStyle: '#BADA55',
|
fillColor: '#BADA55',
|
||||||
strokeStyle: '#013',
|
strokeColor: '#013',
|
||||||
strokeWidth: 2
|
strokeWidth: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ describe('ol.style.Shape', function() {
|
|||||||
expect(literal).toBeA(ol.style.ShapeLiteral);
|
expect(literal).toBeA(ol.style.ShapeLiteral);
|
||||||
expect(literal.size).toBe(10);
|
expect(literal.size).toBe(10);
|
||||||
expect(literal.opacity).toBe(1);
|
expect(literal.opacity).toBe(1);
|
||||||
expect(literal.fillStyle).toBe('#BADA55');
|
expect(literal.fillColor).toBe('#BADA55');
|
||||||
expect(literal.strokeStyle).toBe('#013');
|
expect(literal.strokeColor).toBe('#013');
|
||||||
expect(literal.strokeWidth).toBe(2);
|
expect(literal.strokeWidth).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ describe('ol.style.Shape', function() {
|
|||||||
var symbolizer = new ol.style.Shape({
|
var symbolizer = new ol.style.Shape({
|
||||||
size: new ol.Expression('sizeAttr'),
|
size: new ol.Expression('sizeAttr'),
|
||||||
opacity: new ol.Expression('opacityAttr'),
|
opacity: new ol.Expression('opacityAttr'),
|
||||||
fillStyle: '#BADA55'
|
fillColor: '#BADA55'
|
||||||
});
|
});
|
||||||
|
|
||||||
var feature = new ol.Feature({
|
var feature = new ol.Feature({
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ describe('ol.style.Style', function() {
|
|||||||
symbolizers: [
|
symbolizers: [
|
||||||
new ol.style.Shape({
|
new ol.style.Shape({
|
||||||
size: 4,
|
size: 4,
|
||||||
fillStyle: '#BADA55'
|
fillColor: '#BADA55'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@@ -24,7 +24,7 @@ describe('ol.style.Style', function() {
|
|||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.set('foo', 'bar');
|
feature.set('foo', 'bar');
|
||||||
expect(style.apply(feature).length).toBe(1);
|
expect(style.apply(feature).length).toBe(1);
|
||||||
expect(style.apply(feature)[0].fillStyle).toBe('#BADA55');
|
expect(style.apply(feature)[0].fillColor).toBe('#BADA55');
|
||||||
feature.set('foo', 'baz');
|
feature.set('foo', 'baz');
|
||||||
expect(style.apply(feature).length).toBe(0);
|
expect(style.apply(feature).length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user