Default value for zIndex

This commit is contained in:
Tim Schaub
2013-10-02 16:37:19 -06:00
parent 43c581ef5f
commit bfa257eac1
20 changed files with 262 additions and 124 deletions

View File

@@ -43,7 +43,7 @@ ol.style.Fill = function(opt_options) {
* @private
*/
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
null :
new ol.expr.Literal(ol.style.FillDefaults.zIndex) :
(options.zIndex instanceof ol.expr.Expression) ?
options.zIndex : new ol.expr.Literal(options.zIndex);
@@ -76,11 +76,8 @@ 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;
if (!goog.isNull(this.zIndex_)) {
zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
goog.asserts.assert(!isNaN(zIndex), 'zIndex 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,
@@ -151,10 +148,12 @@ ol.style.Fill.prototype.setZIndex = function(zIndex) {
/**
* @typedef {{fillColor: (string),
* fillOpacity: (number)}}
* @typedef {{fillColor: string,
* fillOpacity: number,
* zIndex: number}}
*/
ol.style.FillDefaults = {
color: '#ffffff',
opacity: 0.4
opacity: 0.4,
zIndex: 0
};

View File

@@ -1,5 +1,6 @@
goog.provide('ol.style.IconLiteral');
goog.require('goog.asserts');
goog.require('ol.style.PointLiteral');
@@ -11,7 +12,7 @@ goog.require('ol.style.PointLiteral');
* rotation: number,
* xOffset: number,
* yOffset: number,
* zIndex: (number|undefined)}}
* zIndex: number}}
*/
ol.style.IconLiteralOptions;
@@ -45,7 +46,9 @@ ol.style.IconLiteral = function(options) {
/** @type {number} */
this.yOffset = options.yOffset;
/** @type {number|undefined} */
goog.asserts.assertNumber(
options.zIndex, 'zIndex must be a number');
/** @type {number} */
this.zIndex = options.zIndex;
};

View File

@@ -86,7 +86,7 @@ ol.style.Icon = function(options) {
* @private
*/
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
null :
new ol.expr.Literal(ol.style.IconDefaults.zIndex) :
(options.zIndex instanceof ol.expr.Expression) ?
options.zIndex : new ol.expr.Literal(options.zIndex);
@@ -139,11 +139,8 @@ 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;
if (!goog.isNull(this.zIndex_)) {
zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
goog.asserts.assert(!isNaN(zIndex), 'zIndex 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,
@@ -317,11 +314,13 @@ ol.style.Icon.prototype.setZIndex = function(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
};

View File

@@ -5,10 +5,10 @@ goog.require('ol.style.Literal');
/**
* @typedef {{color: (string),
* opacity: (number),
* width: (number),
* zIndex: (number|undefined)}}
* @typedef {{color: string,
* opacity: number,
* width: number,
* zIndex: number}}
*/
ol.style.LineLiteralOptions;
@@ -37,7 +37,9 @@ ol.style.LineLiteral = function(options) {
/** @type {number} */
this.width = options.width;
/** @type {number|undefined} */
goog.asserts.assertNumber(
options.zIndex, 'zIndex must be a number');
/** @type {number} */
this.zIndex = options.zIndex;
};

View File

@@ -10,7 +10,7 @@ goog.require('ol.style.Literal');
* strokeColor: (string|undefined),
* strokeOpacity: (number|undefined),
* strokeWidth: (number|undefined),
* zIndex: (number|undefined)}}
* zIndex: number}}
*/
ol.style.PolygonLiteralOptions;
@@ -67,7 +67,9 @@ ol.style.PolygonLiteral = function(options) {
'Either fillColor and fillOpacity or ' +
'strokeColor and strokeOpacity and strokeWidth must be set');
/** @type {number|undefined} */
goog.asserts.assertNumber(
options.zIndex, 'zIndex must be a number');
/** @type {number} */
this.zIndex = options.zIndex;
};

View File

@@ -21,7 +21,7 @@ ol.style.ShapeType = {
* strokeColor: (string|undefined),
* strokeOpacity: (number|undefined),
* strokeWidth: (number|undefined),
* zIndex: (number|undefined)}}
* zIndex: number}}
*/
ol.style.ShapeLiteralOptions;
@@ -85,7 +85,9 @@ ol.style.ShapeLiteral = function(options) {
'Either fillColor and fillOpacity or ' +
'strokeColor and strokeOpacity and strokeWidth must be set');
/** @type {number|undefined} */
goog.asserts.assertNumber(
options.zIndex, 'zIndex must be a number');
/** @type {number} */
this.zIndex = options.zIndex;
};

View File

@@ -58,7 +58,7 @@ ol.style.Shape = function(options) {
* @private
*/
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
null :
new ol.expr.Literal(ol.style.ShapeDefaults.zIndex) :
(options.zIndex instanceof ol.expr.Expression) ?
options.zIndex : new ol.expr.Literal(options.zIndex);
@@ -109,11 +109,8 @@ ol.style.Shape.prototype.createLiteral = function(featureOrType) {
goog.asserts.assert(!isNaN(strokeWidth), 'strokeWidth must be a number');
}
var zIndex;
if (!goog.isNull(this.zIndex_)) {
zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
goog.asserts.assert(!isNaN(zIndex), 'zIndex 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_,
@@ -230,10 +227,12 @@ ol.style.Shape.prototype.setZIndex = function(zIndex) {
/**
* @typedef {{type: (ol.style.ShapeType),
* size: (number)}}
* @typedef {{type: ol.style.ShapeType,
* size: number,
* zIndex: number}}
*/
ol.style.ShapeDefaults = {
type: ol.style.ShapeType.CIRCLE,
size: 5
size: 5,
zIndex: 0
};

View File

@@ -54,7 +54,7 @@ ol.style.Stroke = function(opt_options) {
* @private
*/
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
null :
new ol.expr.Literal(ol.style.StrokeDefaults.zIndex) :
(options.zIndex instanceof ol.expr.Expression) ?
options.zIndex : new ol.expr.Literal(options.zIndex);
@@ -88,11 +88,8 @@ ol.style.Stroke.prototype.createLiteral = function(featureOrType) {
this.width_, feature));
goog.asserts.assert(!isNaN(width), 'width must be a number');
var zIndex;
if (!goog.isNull(this.zIndex_)) {
zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
goog.asserts.assert(!isNaN(zIndex), 'zIndex 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 ||
@@ -194,24 +191,28 @@ ol.style.Stroke.prototype.setZIndex = function(zIndex) {
/**
* @typedef {{strokeColor: (string),
* strokeOpacity: (number),
* strokeWidth: (number)}}
* @typedef {{strokeColor: string,
* strokeOpacity: number,
* strokeWidth: number,
* zIndex: number}}
*/
ol.style.StrokeDefaults = {
color: '#696969',
opacity: 0.75,
width: 1.5
width: 1.5,
zIndex: 0
};
/**
* @typedef {{color: (string),
* opacity: (number),
* width: (number)}}
* @typedef {{color: string,
* opacity: number,
* width: number,
* zIndex: number}}
*/
ol.style.StrokeDefaultsSelect = {
color: '#696969',
opacity: 0.9,
width: 2.0
width: 2.0,
zIndex: 0
};

View File

@@ -10,7 +10,7 @@ goog.require('ol.style.Literal');
* fontSize: number,
* text: string,
* opacity: number,
* zIndex: (number|undefined)}}
* zIndex: number}}
*/
ol.style.TextLiteralOptions;
@@ -43,7 +43,8 @@ ol.style.TextLiteral = function(options) {
/** @type {number} */
this.opacity = options.opacity;
/** @type {number|undefined} */
goog.asserts.assertNumber(options.zIndex, 'zIndex must be a number');
/** @type {number} */
this.zIndex = options.zIndex;
};

View File

@@ -65,7 +65,7 @@ ol.style.Text = function(options) {
* @private
*/
this.zIndex_ = !goog.isDefAndNotNull(options.zIndex) ?
null :
new ol.expr.Literal(ol.style.TextDefaults.zIndex) :
(options.zIndex instanceof ol.expr.Expression) ?
options.zIndex : new ol.expr.Literal(options.zIndex);
@@ -102,11 +102,8 @@ 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;
if (!goog.isNull(this.zIndex_)) {
zIndex = Number(ol.expr.evaluateFeature(this.zIndex_, feature));
goog.asserts.assert(!isNaN(zIndex), 'zIndex 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,
@@ -237,11 +234,13 @@ ol.style.Text.prototype.setZIndex = function(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
};