Merge pull request #1090 from tschaub/symbolizer-z
Add zIndex property to symbolizers. Symbolizers with the same zIndex (in addition to other properties) are considered equal. A subsequent change will sort features by symbolizer zIndex before rendering.
This commit is contained in:
@@ -692,6 +692,7 @@
|
||||
* point to the center of the icon (positive values shift image left).
|
||||
* @property {number|ol.expr.Expression|undefined} yOffset Pixel offset from the
|
||||
* point to the center of the icon (positive values shift image down).
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -699,6 +700,7 @@
|
||||
* @property {string|ol.expr.Expression|undefined} color Fill color as hex color
|
||||
* code.
|
||||
* @property {number|ol.expr.Expression|undefined} opacity Opacity (0-1).
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -719,6 +721,7 @@
|
||||
* @property {number|ol.expr.Expression|undefined} size Size in pixels.
|
||||
* @property {ol.style.Fill|undefined} fill Fill symbolizer for shape.
|
||||
* @property {ol.style.Stroke|undefined} stroke Stroke symbolizer for shape.
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -727,6 +730,7 @@
|
||||
* color code.
|
||||
* @property {number|ol.expr.Expression|undefined} opacity Stroke opacity (0-1).
|
||||
* @property {number|ol.expr.Expression|undefined} width Stroke width in pixels.
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -744,6 +748,7 @@
|
||||
* @property {number|ol.expr.Expression|undefined} fontSize Font size in pixels.
|
||||
* @property {string|ol.expr.Expression} text Text for the label.
|
||||
* @property {number|ol.expr.Expression|undefined} opacity Opacity (0-1).
|
||||
* @property {number|ol.expr.Expression|undefined} zIndex Stack order.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,15 @@ ol.style.Fill = function(opt_options) {
|
||||
(options.opacity instanceof ol.expr.Expression) ?
|
||||
options.opacity : new ol.expr.Literal(options.opacity);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
|
||||
new ol.expr.Literal(ol.style.FillDefaults.zIndex) :
|
||||
(options.zIndex instanceof ol.expr.Expression) ?
|
||||
options.zIndex : new ol.expr.Literal(options.zIndex);
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.Fill, ol.style.Symbolizer);
|
||||
|
||||
@@ -67,9 +76,13 @@ ol.style.Fill.prototype.createLiteral = function(featureOrType) {
|
||||
var opacity = Number(ol.expr.evaluateFeature(this.opacity_, feature));
|
||||
goog.asserts.assert(!isNaN(opacity), 'opacity must be a number');
|
||||
|
||||
var zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
|
||||
goog.asserts.assert(!isNaN(zIndex), 'zIndex must be a number');
|
||||
|
||||
literal = new ol.style.PolygonLiteral({
|
||||
fillColor: color,
|
||||
fillOpacity: opacity
|
||||
fillOpacity: opacity,
|
||||
zIndex: zIndex
|
||||
});
|
||||
}
|
||||
|
||||
@@ -95,6 +108,15 @@ ol.style.Fill.prototype.getOpacity = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the fill zIndex.
|
||||
* @return {ol.expr.Expression} Fill zIndex.
|
||||
*/
|
||||
ol.style.Fill.prototype.getZIndex = function() {
|
||||
return this.zIndex_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the fill color.
|
||||
* @param {ol.expr.Expression} color Fill color.
|
||||
@@ -116,10 +138,22 @@ ol.style.Fill.prototype.setOpacity = function(opacity) {
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: (string),
|
||||
* opacity: (number)}}
|
||||
* Set the fill zIndex.
|
||||
* @param {ol.expr.Expression} zIndex Fill zIndex.
|
||||
*/
|
||||
ol.style.Fill.prototype.setZIndex = function(zIndex) {
|
||||
goog.asserts.assertInstanceof(zIndex, ol.expr.Expression);
|
||||
this.zIndex_ = zIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{fillColor: string,
|
||||
* fillOpacity: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.FillDefaults = {
|
||||
color: '#ffffff',
|
||||
opacity: 0.4
|
||||
opacity: 0.4,
|
||||
zIndex: 0
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.style.IconLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.PointLiteral');
|
||||
|
||||
|
||||
@@ -10,7 +11,8 @@ goog.require('ol.style.PointLiteral');
|
||||
* opacity: number,
|
||||
* rotation: number,
|
||||
* xOffset: number,
|
||||
* yOffset: number}}
|
||||
* yOffset: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.IconLiteralOptions;
|
||||
|
||||
@@ -44,6 +46,11 @@ ol.style.IconLiteral = function(options) {
|
||||
/** @type {number} */
|
||||
this.yOffset = options.yOffset;
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.zIndex, 'zIndex must be a number');
|
||||
/** @type {number} */
|
||||
this.zIndex = options.zIndex;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.IconLiteral, ol.style.PointLiteral);
|
||||
|
||||
@@ -51,12 +58,13 @@ goog.inherits(ol.style.IconLiteral, ol.style.PointLiteral);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.IconLiteral.prototype.equals = function(iconLiteral) {
|
||||
return this.url == iconLiteral.url &&
|
||||
this.width == iconLiteral.width &&
|
||||
this.height == iconLiteral.height &&
|
||||
this.opacity == iconLiteral.opacity &&
|
||||
this.rotation == iconLiteral.rotation &&
|
||||
this.xOffset == iconLiteral.xOffset &&
|
||||
this.yOffset == iconLiteral.yOffset;
|
||||
ol.style.IconLiteral.prototype.equals = function(other) {
|
||||
return this.url == other.url &&
|
||||
this.width == other.width &&
|
||||
this.height == other.height &&
|
||||
this.opacity == other.opacity &&
|
||||
this.rotation == other.rotation &&
|
||||
this.xOffset == other.xOffset &&
|
||||
this.yOffset == other.yOffset &&
|
||||
this.zIndex == other.zIndex;
|
||||
};
|
||||
|
||||
@@ -81,6 +81,15 @@ ol.style.Icon = function(options) {
|
||||
(options.yOffset instanceof ol.expr.Expression) ?
|
||||
options.yOffset : new ol.expr.Literal(options.yOffset);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
|
||||
new ol.expr.Literal(ol.style.IconDefaults.zIndex) :
|
||||
(options.zIndex instanceof ol.expr.Expression) ?
|
||||
options.zIndex : new ol.expr.Literal(options.zIndex);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -130,6 +139,9 @@ ol.style.Icon.prototype.createLiteral = function(featureOrType) {
|
||||
var yOffset = Number(ol.expr.evaluateFeature(this.yOffset_, feature));
|
||||
goog.asserts.assert(!isNaN(yOffset), 'yOffset must be a number');
|
||||
|
||||
var zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
|
||||
goog.asserts.assert(!isNaN(zIndex), 'zIndex must be a number');
|
||||
|
||||
literal = new ol.style.IconLiteral({
|
||||
url: url,
|
||||
width: width,
|
||||
@@ -137,7 +149,8 @@ ol.style.Icon.prototype.createLiteral = function(featureOrType) {
|
||||
opacity: opacity,
|
||||
rotation: rotation,
|
||||
xOffset: xOffset,
|
||||
yOffset: yOffset
|
||||
yOffset: yOffset,
|
||||
zIndex: zIndex
|
||||
});
|
||||
}
|
||||
|
||||
@@ -208,6 +221,15 @@ ol.style.Icon.prototype.getYOffset = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the zIndex.
|
||||
* @return {ol.expr.Expression} Icon zIndex.
|
||||
*/
|
||||
ol.style.Icon.prototype.getZIndex = function() {
|
||||
return this.zIndex_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the height.
|
||||
* @param {ol.expr.Expression} height Icon height.
|
||||
@@ -278,15 +300,27 @@ ol.style.Icon.prototype.setYOffset = function(yOffset) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the zIndex.
|
||||
* @param {ol.expr.Expression} zIndex Icon zIndex.
|
||||
*/
|
||||
ol.style.Icon.prototype.setZIndex = function(zIndex) {
|
||||
goog.asserts.assertInstanceof(zIndex, ol.expr.Expression);
|
||||
this.zIndex_ = zIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{opacity: number,
|
||||
* rotation: number,
|
||||
* xOffset: number,
|
||||
* yOffset: number}}
|
||||
* yOffset: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.IconDefaults = {
|
||||
opacity: 1,
|
||||
rotation: 0,
|
||||
xOffset: 0,
|
||||
yOffset: 0
|
||||
yOffset: 0,
|
||||
zIndex: 0
|
||||
};
|
||||
|
||||
@@ -5,9 +5,10 @@ goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: (string),
|
||||
* opacity: (number),
|
||||
* width: (number)}}
|
||||
* @typedef {{color: string,
|
||||
* opacity: number,
|
||||
* width: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.LineLiteralOptions;
|
||||
|
||||
@@ -36,6 +37,11 @@ ol.style.LineLiteral = function(options) {
|
||||
/** @type {number} */
|
||||
this.width = options.width;
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.zIndex, 'zIndex must be a number');
|
||||
/** @type {number} */
|
||||
this.zIndex = options.zIndex;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.LineLiteral, ol.style.Literal);
|
||||
|
||||
@@ -43,8 +49,9 @@ goog.inherits(ol.style.LineLiteral, ol.style.Literal);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.LineLiteral.prototype.equals = function(lineLiteral) {
|
||||
return this.color == lineLiteral.color &&
|
||||
this.opacity == lineLiteral.opacity &&
|
||||
this.width == lineLiteral.width;
|
||||
ol.style.LineLiteral.prototype.equals = function(other) {
|
||||
return this.color == other.color &&
|
||||
this.opacity == other.opacity &&
|
||||
this.width == other.width &&
|
||||
this.zIndex == other.zIndex;
|
||||
};
|
||||
|
||||
@@ -9,7 +9,8 @@ goog.require('ol.style.Literal');
|
||||
* fillOpacity: (number|undefined),
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined)}}
|
||||
* strokeWidth: (number|undefined),
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.PolygonLiteralOptions;
|
||||
|
||||
@@ -66,6 +67,11 @@ ol.style.PolygonLiteral = function(options) {
|
||||
'Either fillColor and fillOpacity or ' +
|
||||
'strokeColor and strokeOpacity and strokeWidth must be set');
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.zIndex, 'zIndex must be a number');
|
||||
/** @type {number} */
|
||||
this.zIndex = options.zIndex;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.PolygonLiteral, ol.style.Literal);
|
||||
|
||||
@@ -73,10 +79,11 @@ goog.inherits(ol.style.PolygonLiteral, ol.style.Literal);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.PolygonLiteral.prototype.equals = function(polygonLiteral) {
|
||||
return this.fillColor == polygonLiteral.fillColor &&
|
||||
this.fillOpacity == polygonLiteral.fillOpacity &&
|
||||
this.strokeColor == polygonLiteral.strokeColor &&
|
||||
this.strokeOpacity == polygonLiteral.strokeOpacity &&
|
||||
this.strokeWidth == polygonLiteral.strokeWidth;
|
||||
ol.style.PolygonLiteral.prototype.equals = function(other) {
|
||||
return this.fillColor == other.fillColor &&
|
||||
this.fillOpacity == other.fillOpacity &&
|
||||
this.strokeColor == other.strokeColor &&
|
||||
this.strokeOpacity == other.strokeOpacity &&
|
||||
this.strokeWidth == other.strokeWidth &&
|
||||
this.zIndex == other.zIndex;
|
||||
};
|
||||
|
||||
@@ -20,7 +20,8 @@ ol.style.ShapeType = {
|
||||
* fillOpacity: (number|undefined),
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined)}}
|
||||
* strokeWidth: (number|undefined),
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.ShapeLiteralOptions;
|
||||
|
||||
@@ -84,6 +85,11 @@ ol.style.ShapeLiteral = function(options) {
|
||||
'Either fillColor and fillOpacity or ' +
|
||||
'strokeColor and strokeOpacity and strokeWidth must be set');
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.zIndex, 'zIndex must be a number');
|
||||
/** @type {number} */
|
||||
this.zIndex = options.zIndex;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.ShapeLiteral, ol.style.PointLiteral);
|
||||
|
||||
@@ -91,12 +97,13 @@ goog.inherits(ol.style.ShapeLiteral, ol.style.PointLiteral);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.ShapeLiteral.prototype.equals = function(shapeLiteral) {
|
||||
return this.type == shapeLiteral.type &&
|
||||
this.size == shapeLiteral.size &&
|
||||
this.fillColor == shapeLiteral.fillColor &&
|
||||
this.fillOpacity == shapeLiteral.fillOpacity &&
|
||||
this.strokeColor == shapeLiteral.strokeColor &&
|
||||
this.strokeOpacity == shapeLiteral.strokeOpacity &&
|
||||
this.strokeWidth == shapeLiteral.strokeWidth;
|
||||
ol.style.ShapeLiteral.prototype.equals = function(other) {
|
||||
return this.type == other.type &&
|
||||
this.size == other.size &&
|
||||
this.fillColor == other.fillColor &&
|
||||
this.fillOpacity == other.fillOpacity &&
|
||||
this.strokeColor == other.strokeColor &&
|
||||
this.strokeOpacity == other.strokeOpacity &&
|
||||
this.strokeWidth == other.strokeWidth &&
|
||||
this.zIndex == other.zIndex;
|
||||
};
|
||||
|
||||
@@ -53,6 +53,15 @@ ol.style.Shape = function(options) {
|
||||
goog.asserts.assert(this.fill_ || this.stroke_,
|
||||
'Stroke or fill must be provided');
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
|
||||
new ol.expr.Literal(ol.style.ShapeDefaults.zIndex) :
|
||||
(options.zIndex instanceof ol.expr.Expression) ?
|
||||
options.zIndex : new ol.expr.Literal(options.zIndex);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -100,6 +109,9 @@ ol.style.Shape.prototype.createLiteral = function(featureOrType) {
|
||||
goog.asserts.assert(!isNaN(strokeWidth), 'strokeWidth must be a number');
|
||||
}
|
||||
|
||||
var zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
|
||||
goog.asserts.assert(!isNaN(zIndex), 'zIndex must be a number');
|
||||
|
||||
literal = new ol.style.ShapeLiteral({
|
||||
type: this.type_,
|
||||
size: size,
|
||||
@@ -107,7 +119,8 @@ ol.style.Shape.prototype.createLiteral = function(featureOrType) {
|
||||
fillOpacity: fillOpacity,
|
||||
strokeColor: strokeColor,
|
||||
strokeOpacity: strokeOpacity,
|
||||
strokeWidth: strokeWidth
|
||||
strokeWidth: strokeWidth,
|
||||
zIndex: zIndex
|
||||
});
|
||||
}
|
||||
|
||||
@@ -151,6 +164,15 @@ ol.style.Shape.prototype.getType = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the shape zIndex.
|
||||
* @return {ol.expr.Expression} Shape zIndex.
|
||||
*/
|
||||
ol.style.Shape.prototype.getZIndex = function() {
|
||||
return this.zIndex_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the fill.
|
||||
* @param {ol.style.Fill} fill Shape fill.
|
||||
@@ -195,10 +217,22 @@ ol.style.Shape.prototype.setType = function(type) {
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{type: (ol.style.ShapeType),
|
||||
* size: (number)}}
|
||||
* Set the shape zIndex.
|
||||
* @param {ol.expr.Expression} zIndex Shape zIndex.
|
||||
*/
|
||||
ol.style.Shape.prototype.setZIndex = function(zIndex) {
|
||||
goog.asserts.assertInstanceof(zIndex, ol.expr.Expression);
|
||||
this.zIndex_ = zIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{type: ol.style.ShapeType,
|
||||
* size: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.ShapeDefaults = {
|
||||
type: ol.style.ShapeType.CIRCLE,
|
||||
size: 5
|
||||
size: 5,
|
||||
zIndex: 0
|
||||
};
|
||||
|
||||
@@ -49,6 +49,15 @@ ol.style.Stroke = function(opt_options) {
|
||||
(options.width instanceof ol.expr.Expression) ?
|
||||
options.width : new ol.expr.Literal(options.width);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
|
||||
new ol.expr.Literal(ol.style.StrokeDefaults.zIndex) :
|
||||
(options.zIndex instanceof ol.expr.Expression) ?
|
||||
options.zIndex : new ol.expr.Literal(options.zIndex);
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.Stroke, ol.style.Symbolizer);
|
||||
|
||||
@@ -79,20 +88,25 @@ ol.style.Stroke.prototype.createLiteral = function(featureOrType) {
|
||||
this.width_, feature));
|
||||
goog.asserts.assert(!isNaN(width), 'width must be a number');
|
||||
|
||||
var zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
|
||||
goog.asserts.assert(!isNaN(zIndex), 'zIndex must be a number');
|
||||
|
||||
var literal = null;
|
||||
if (type === ol.geom.GeometryType.LINESTRING ||
|
||||
type === ol.geom.GeometryType.MULTILINESTRING) {
|
||||
literal = new ol.style.LineLiteral({
|
||||
color: color,
|
||||
opacity: opacity,
|
||||
width: width
|
||||
width: width,
|
||||
zIndex: zIndex
|
||||
});
|
||||
} else if (type === ol.geom.GeometryType.POLYGON ||
|
||||
type === ol.geom.GeometryType.MULTIPOLYGON) {
|
||||
literal = new ol.style.PolygonLiteral({
|
||||
strokeColor: color,
|
||||
strokeOpacity: opacity,
|
||||
strokeWidth: width
|
||||
strokeWidth: width,
|
||||
zIndex: zIndex
|
||||
});
|
||||
}
|
||||
|
||||
@@ -127,6 +141,15 @@ ol.style.Stroke.prototype.getWidth = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the stroke zIndex.
|
||||
* @return {ol.expr.Expression} Stroke zIndex.
|
||||
*/
|
||||
ol.style.Stroke.prototype.getZIndex = function() {
|
||||
return this.zIndex_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the stroke color.
|
||||
* @param {ol.expr.Expression} color Stroke color.
|
||||
@@ -158,24 +181,24 @@ ol.style.Stroke.prototype.setWidth = function(width) {
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: (string),
|
||||
* opacity: (number),
|
||||
* width: (number)}}
|
||||
* Set the stroke zIndex.
|
||||
* @param {ol.expr.Expression} zIndex Stroke zIndex.
|
||||
*/
|
||||
ol.style.StrokeDefaults = {
|
||||
color: '#696969',
|
||||
opacity: 0.75,
|
||||
width: 1.5
|
||||
ol.style.Stroke.prototype.setZIndex = function(zIndex) {
|
||||
goog.asserts.assertInstanceof(zIndex, ol.expr.Expression);
|
||||
this.zIndex_ = zIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: (string),
|
||||
* opacity: (number),
|
||||
* width: (number)}}
|
||||
* @typedef {{strokeColor: string,
|
||||
* strokeOpacity: number,
|
||||
* strokeWidth: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.StrokeDefaultsSelect = {
|
||||
ol.style.StrokeDefaults = {
|
||||
color: '#696969',
|
||||
opacity: 0.9,
|
||||
width: 2.0
|
||||
opacity: 0.75,
|
||||
width: 1.5,
|
||||
zIndex: 0
|
||||
};
|
||||
|
||||
@@ -9,7 +9,8 @@ goog.require('ol.style.Literal');
|
||||
* fontFamily: string,
|
||||
* fontSize: number,
|
||||
* text: string,
|
||||
* opacity: number}}
|
||||
* opacity: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.TextLiteralOptions;
|
||||
|
||||
@@ -42,6 +43,10 @@ ol.style.TextLiteral = function(options) {
|
||||
/** @type {number} */
|
||||
this.opacity = options.opacity;
|
||||
|
||||
goog.asserts.assertNumber(options.zIndex, 'zIndex must be a number');
|
||||
/** @type {number} */
|
||||
this.zIndex = options.zIndex;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.TextLiteral, ol.style.Literal);
|
||||
|
||||
@@ -49,9 +54,10 @@ goog.inherits(ol.style.TextLiteral, ol.style.Literal);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.TextLiteral.prototype.equals = function(textLiteral) {
|
||||
return this.color == textLiteral.color &&
|
||||
this.fontFamily == textLiteral.fontFamily &&
|
||||
this.fontSize == textLiteral.fontSize &&
|
||||
this.opacity == textLiteral.opacity;
|
||||
ol.style.TextLiteral.prototype.equals = function(other) {
|
||||
return this.color == other.color &&
|
||||
this.fontFamily == other.fontFamily &&
|
||||
this.fontSize == other.fontSize &&
|
||||
this.opacity == other.opacity &&
|
||||
this.zIndex == other.zIndex;
|
||||
};
|
||||
|
||||
@@ -60,6 +60,15 @@ ol.style.Text = function(options) {
|
||||
(options.opacity instanceof ol.expr.Expression) ?
|
||||
options.opacity : new ol.expr.Literal(options.opacity);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
|
||||
new ol.expr.Literal(ol.style.TextDefaults.zIndex) :
|
||||
(options.zIndex instanceof ol.expr.Expression) ?
|
||||
options.zIndex : new ol.expr.Literal(options.zIndex);
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.Text, ol.style.Symbolizer);
|
||||
|
||||
@@ -93,12 +102,16 @@ ol.style.Text.prototype.createLiteral = function(featureOrType) {
|
||||
var opacity = Number(ol.expr.evaluateFeature(this.opacity_, feature));
|
||||
goog.asserts.assert(!isNaN(opacity), 'opacity must be a number');
|
||||
|
||||
var zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
|
||||
goog.asserts.assert(!isNaN(zIndex), 'zIndex must be a number');
|
||||
|
||||
return new ol.style.TextLiteral({
|
||||
color: color,
|
||||
fontFamily: fontFamily,
|
||||
fontSize: fontSize,
|
||||
text: text,
|
||||
opacity: opacity
|
||||
opacity: opacity,
|
||||
zIndex: zIndex
|
||||
});
|
||||
};
|
||||
|
||||
@@ -148,6 +161,15 @@ ol.style.Text.prototype.getText = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the zIndex.
|
||||
* @return {ol.expr.Expression} Text.
|
||||
*/
|
||||
ol.style.Text.prototype.getZIndex = function() {
|
||||
return this.zIndex_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the font color.
|
||||
* @param {ol.expr.Expression} color Font color.
|
||||
@@ -198,15 +220,27 @@ ol.style.Text.prototype.setText = function(text) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the zIndex.
|
||||
* @param {ol.expr.Expression} zIndex Text.
|
||||
*/
|
||||
ol.style.Text.prototype.setZIndex = function(zIndex) {
|
||||
goog.asserts.assertInstanceof(zIndex, ol.expr.Expression);
|
||||
this.zIndex_ = zIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: string,
|
||||
* fontFamily: string,
|
||||
* fontSize: number,
|
||||
* opacity: number}}
|
||||
* opacity: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.TextDefaults = {
|
||||
color: '#000',
|
||||
fontFamily: 'sans-serif',
|
||||
fontSize: 10,
|
||||
opacity: 1
|
||||
opacity: 1,
|
||||
zIndex: 0
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user