Move vector code out of the way
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
goog.provide('ol.style.Fill');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.style.PolygonLiteral');
|
||||
goog.require('ol.style.Symbolizer');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Symbolizer}
|
||||
* @param {ol.style.FillOptions=} opt_options Polygon options.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.style.Fill = function(opt_options) {
|
||||
goog.base(this);
|
||||
var options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.color_ = !goog.isDefAndNotNull(options.color) ?
|
||||
new ol.expr.Literal(ol.style.FillDefaults.color) :
|
||||
(options.color instanceof ol.expr.Expression) ?
|
||||
options.color : new ol.expr.Literal(options.color);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.opacity_ = !goog.isDefAndNotNull(options.opacity) ?
|
||||
new ol.expr.Literal(ol.style.FillDefaults.opacity) :
|
||||
(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);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return {ol.style.PolygonLiteral} Literal shape symbolizer.
|
||||
*/
|
||||
ol.style.Fill.prototype.createLiteral = function(featureOrType) {
|
||||
var feature, type;
|
||||
if (featureOrType instanceof ol.Feature) {
|
||||
feature = featureOrType;
|
||||
var geometry = feature.getGeometry();
|
||||
type = geometry ? geometry.getType() : null;
|
||||
} else {
|
||||
type = featureOrType;
|
||||
}
|
||||
var literal = null;
|
||||
|
||||
if (type === ol.geom.GeometryType.POLYGON ||
|
||||
type === ol.geom.GeometryType.MULTIPOLYGON) {
|
||||
|
||||
var color = ol.expr.evaluateFeature(this.color_, feature);
|
||||
goog.asserts.assertString(
|
||||
color, 'color must be a string');
|
||||
|
||||
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,
|
||||
zIndex: zIndex
|
||||
});
|
||||
}
|
||||
|
||||
return literal;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the fill color.
|
||||
* @return {ol.expr.Expression} Fill color.
|
||||
*/
|
||||
ol.style.Fill.prototype.getColor = function() {
|
||||
return this.color_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the fill opacity.
|
||||
* @return {ol.expr.Expression} Fill opacity.
|
||||
*/
|
||||
ol.style.Fill.prototype.getOpacity = function() {
|
||||
return this.opacity_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ol.style.Fill.prototype.setColor = function(color) {
|
||||
goog.asserts.assertInstanceof(color, ol.expr.Expression);
|
||||
this.color_ = color;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the fill opacity.
|
||||
* @param {ol.expr.Expression} opacity Fill opacity.
|
||||
*/
|
||||
ol.style.Fill.prototype.setOpacity = function(opacity) {
|
||||
goog.asserts.assertInstanceof(opacity, ol.expr.Expression);
|
||||
this.opacity_ = opacity;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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,
|
||||
zIndex: 0
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
goog.provide('ol.style.IconLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.PointLiteral');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{url: string,
|
||||
* width: (number|undefined),
|
||||
* height: (number|undefined),
|
||||
* opacity: number,
|
||||
* rotation: number,
|
||||
* xOffset: number,
|
||||
* yOffset: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.IconLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.PointLiteral}
|
||||
* @param {ol.style.IconLiteralOptions} options Icon literal options.
|
||||
*/
|
||||
ol.style.IconLiteral = function(options) {
|
||||
|
||||
/** @type {string} */
|
||||
this.url = options.url;
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.width = options.width;
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.height = options.height;
|
||||
|
||||
/** @type {number} */
|
||||
this.opacity = options.opacity;
|
||||
|
||||
/** @type {number} */
|
||||
this.rotation = options.rotation;
|
||||
|
||||
/** @type {number} */
|
||||
this.xOffset = options.xOffset;
|
||||
|
||||
/** @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);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
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;
|
||||
};
|
||||
@@ -0,0 +1,329 @@
|
||||
goog.provide('ol.style.Icon');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.style.IconLiteral');
|
||||
goog.require('ol.style.Point');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Point}
|
||||
* @param {ol.style.IconOptions} options Icon options.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.style.Icon = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
goog.asserts.assert(options.url, 'url must be set');
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.url_ = (options.url instanceof ol.expr.Expression) ?
|
||||
options.url : new ol.expr.Literal(options.url);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.width_ = !goog.isDef(options.width) ?
|
||||
null :
|
||||
(options.width instanceof ol.expr.Expression) ?
|
||||
options.width : new ol.expr.Literal(options.width);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.height_ = !goog.isDef(options.height) ?
|
||||
null :
|
||||
(options.height instanceof ol.expr.Expression) ?
|
||||
options.height : new ol.expr.Literal(options.height);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.opacity_ = !goog.isDef(options.opacity) ?
|
||||
new ol.expr.Literal(ol.style.IconDefaults.opacity) :
|
||||
(options.opacity instanceof ol.expr.Expression) ?
|
||||
options.opacity : new ol.expr.Literal(options.opacity);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.rotation_ = !goog.isDef(options.rotation) ?
|
||||
new ol.expr.Literal(ol.style.IconDefaults.rotation) :
|
||||
(options.rotation instanceof ol.expr.Expression) ?
|
||||
options.rotation : new ol.expr.Literal(options.rotation);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.xOffset_ = !goog.isDef(options.xOffset) ?
|
||||
new ol.expr.Literal(ol.style.IconDefaults.xOffset) :
|
||||
(options.xOffset instanceof ol.expr.Expression) ?
|
||||
options.xOffset : new ol.expr.Literal(options.xOffset);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.yOffset_ = !goog.isDef(options.yOffset) ?
|
||||
new ol.expr.Literal(ol.style.IconDefaults.yOffset) :
|
||||
(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);
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.Icon, ol.style.Point);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return {ol.style.IconLiteral} Literal shape symbolizer.
|
||||
*/
|
||||
ol.style.Icon.prototype.createLiteral = function(featureOrType) {
|
||||
var feature, type;
|
||||
if (featureOrType instanceof ol.Feature) {
|
||||
feature = featureOrType;
|
||||
var geometry = feature.getGeometry();
|
||||
type = geometry ? geometry.getType() : null;
|
||||
} else {
|
||||
type = featureOrType;
|
||||
}
|
||||
|
||||
var literal = null;
|
||||
if (type === ol.geom.GeometryType.POINT ||
|
||||
type === ol.geom.GeometryType.MULTIPOINT) {
|
||||
|
||||
var url = ol.expr.evaluateFeature(this.url_, feature);
|
||||
goog.asserts.assertString(url, 'url must be a string');
|
||||
goog.asserts.assert(url != '#', 'url must not be "#"');
|
||||
|
||||
var width;
|
||||
if (!goog.isNull(this.width_)) {
|
||||
width = Number(ol.expr.evaluateFeature(this.width_, feature));
|
||||
goog.asserts.assert(!isNaN(width), 'width must be a number');
|
||||
}
|
||||
|
||||
var height;
|
||||
if (!goog.isNull(this.height_)) {
|
||||
height = Number(ol.expr.evaluateFeature(this.height_, feature));
|
||||
goog.asserts.assertNumber(height, 'height must be a number');
|
||||
}
|
||||
|
||||
var opacity = Number(ol.expr.evaluateFeature(this.opacity_, feature));
|
||||
goog.asserts.assert(!isNaN(opacity), 'opacity must be a number');
|
||||
|
||||
var rotation = Number(ol.expr.evaluateFeature(this.rotation_, feature));
|
||||
goog.asserts.assert(!isNaN(rotation), 'rotation must be a number');
|
||||
|
||||
var xOffset = Number(ol.expr.evaluateFeature(this.xOffset_, feature));
|
||||
goog.asserts.assert(!isNaN(xOffset), 'xOffset must be a number');
|
||||
|
||||
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,
|
||||
height: height,
|
||||
opacity: opacity,
|
||||
rotation: rotation,
|
||||
xOffset: xOffset,
|
||||
yOffset: yOffset,
|
||||
zIndex: zIndex
|
||||
});
|
||||
}
|
||||
|
||||
return literal;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the height.
|
||||
* @return {ol.expr.Expression} Icon height.
|
||||
*/
|
||||
ol.style.Icon.prototype.getHeight = function() {
|
||||
return this.height_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the opacity.
|
||||
* @return {ol.expr.Expression} Opacity.
|
||||
*/
|
||||
ol.style.Icon.prototype.getOpacity = function() {
|
||||
return this.opacity_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the rotation.
|
||||
* @return {ol.expr.Expression} Icon rotation.
|
||||
*/
|
||||
ol.style.Icon.prototype.getRotation = function() {
|
||||
return this.rotation_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the URL.
|
||||
* @return {ol.expr.Expression} Icon URL.
|
||||
*/
|
||||
ol.style.Icon.prototype.getUrl = function() {
|
||||
return this.url_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the width.
|
||||
* @return {ol.expr.Expression} Icon width.
|
||||
*/
|
||||
ol.style.Icon.prototype.getWidth = function() {
|
||||
return this.width_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the xOffset.
|
||||
* @return {ol.expr.Expression} Icon xOffset.
|
||||
*/
|
||||
ol.style.Icon.prototype.getXOffset = function() {
|
||||
return this.xOffset_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the yOffset.
|
||||
* @return {ol.expr.Expression} Icon yOffset.
|
||||
*/
|
||||
ol.style.Icon.prototype.getYOffset = function() {
|
||||
return this.yOffset_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ol.style.Icon.prototype.setHeight = function(height) {
|
||||
goog.asserts.assertInstanceof(height, ol.expr.Expression);
|
||||
this.height_ = height;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the opacity.
|
||||
* @param {ol.expr.Expression} opacity Opacity.
|
||||
*/
|
||||
ol.style.Icon.prototype.setOpacity = function(opacity) {
|
||||
goog.asserts.assertInstanceof(opacity, ol.expr.Expression);
|
||||
this.opacity_ = opacity;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the rotation.
|
||||
* @param {ol.expr.Expression} rotation Icon rotation.
|
||||
*/
|
||||
ol.style.Icon.prototype.setRotation = function(rotation) {
|
||||
goog.asserts.assertInstanceof(rotation, ol.expr.Expression);
|
||||
this.rotation_ = rotation;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the URL.
|
||||
* @param {ol.expr.Expression} url Icon URL.
|
||||
*/
|
||||
ol.style.Icon.prototype.setUrl = function(url) {
|
||||
goog.asserts.assertInstanceof(url, ol.expr.Expression);
|
||||
this.url_ = url;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the width.
|
||||
* @param {ol.expr.Expression} width Icon width.
|
||||
*/
|
||||
ol.style.Icon.prototype.setWidth = function(width) {
|
||||
goog.asserts.assertInstanceof(width, ol.expr.Expression);
|
||||
this.width_ = width;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the xOffset.
|
||||
* @param {ol.expr.Expression} xOffset Icon xOffset.
|
||||
*/
|
||||
ol.style.Icon.prototype.setXOffset = function(xOffset) {
|
||||
goog.asserts.assertInstanceof(xOffset, ol.expr.Expression);
|
||||
this.xOffset_ = xOffset;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the yOffset.
|
||||
* @param {ol.expr.Expression} yOffset Icon yOffset.
|
||||
*/
|
||||
ol.style.Icon.prototype.setYOffset = function(yOffset) {
|
||||
goog.asserts.assertInstanceof(yOffset, ol.expr.Expression);
|
||||
this.yOffset_ = 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,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.IconDefaults = {
|
||||
opacity: 1,
|
||||
rotation: 0,
|
||||
xOffset: 0,
|
||||
yOffset: 0,
|
||||
zIndex: 0
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
goog.provide('ol.style.LineLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: string,
|
||||
* opacity: number,
|
||||
* width: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.LineLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.LineLiteralOptions} options Line literal options.
|
||||
*/
|
||||
ol.style.LineLiteral = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
goog.asserts.assertString(
|
||||
options.color, 'color must be a string');
|
||||
/** @type {string} */
|
||||
this.color = options.color;
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.opacity, 'opacity must be a number');
|
||||
/** @type {number} */
|
||||
this.opacity = options.opacity;
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.width, 'width must be a number');
|
||||
/** @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);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.LineLiteral.prototype.equals = function(other) {
|
||||
return this.color == other.color &&
|
||||
this.opacity == other.opacity &&
|
||||
this.width == other.width &&
|
||||
this.zIndex == other.zIndex;
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
goog.provide('ol.style.Literal');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
ol.style.Literal = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.style.Literal} symbolizerLiteral Symbolizer literal to
|
||||
* compare to.
|
||||
* @return {boolean} Is the passed symbolizer literal equal to this instance?
|
||||
*/
|
||||
ol.style.Literal.prototype.equals = goog.abstractMethod;
|
||||
@@ -0,0 +1,14 @@
|
||||
goog.provide('ol.style.PointLiteral');
|
||||
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
*/
|
||||
ol.style.PointLiteral = function() {
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.style.PointLiteral, ol.style.Literal);
|
||||
@@ -0,0 +1,20 @@
|
||||
goog.provide('ol.style.Point');
|
||||
|
||||
goog.require('ol.style.Symbolizer');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Symbolizer}
|
||||
*/
|
||||
ol.style.Point = function() {
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.style.Point, ol.style.Symbolizer);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.Point.prototype.createLiteral = goog.abstractMethod;
|
||||
@@ -0,0 +1,89 @@
|
||||
goog.provide('ol.style.PolygonLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{fillColor: (string|undefined),
|
||||
* fillOpacity: (number|undefined),
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined),
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.PolygonLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.PolygonLiteralOptions} options Polygon literal options.
|
||||
*/
|
||||
ol.style.PolygonLiteral = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.fillColor = options.fillColor;
|
||||
if (goog.isDef(options.fillColor)) {
|
||||
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.fillOpacity = options.fillOpacity;
|
||||
if (goog.isDef(options.fillOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
options.fillOpacity, 'fillOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
if (goog.isDef(this.strokeColor)) {
|
||||
goog.asserts.assertString(
|
||||
this.strokeColor, 'strokeColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
if (goog.isDef(this.strokeOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeOpacity, 'strokeOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
if (goog.isDef(this.strokeWidth)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeWidth, 'strokeWidth must be a number');
|
||||
}
|
||||
|
||||
// fill and/or stroke properties must be defined
|
||||
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
|
||||
var strokeDef = goog.isDef(this.strokeColor) &&
|
||||
goog.isDef(this.strokeOpacity) &&
|
||||
goog.isDef(this.strokeWidth);
|
||||
goog.asserts.assert(fillDef || strokeDef,
|
||||
'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);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
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;
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
goog.provide('ol.style.Rule');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.style.Symbolizer');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {ol.style.RuleOptions} options Rule options.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.style.Rule = function(options) {
|
||||
|
||||
|
||||
var filter = null;
|
||||
if (goog.isDef(options.filter)) {
|
||||
if (goog.isString(options.filter)) {
|
||||
filter = ol.expr.parse(options.filter);
|
||||
} else {
|
||||
goog.asserts.assert(options.filter instanceof ol.expr.Expression);
|
||||
filter = options.filter;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.filter_ = filter;
|
||||
|
||||
/**
|
||||
* @type {Array.<ol.style.Symbolizer>}
|
||||
* @private
|
||||
*/
|
||||
this.symbolizers_ = goog.isDef(options.symbolizers) ?
|
||||
options.symbolizers : [];
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.minResolution_ = goog.isDef(options.minResolution) ?
|
||||
options.minResolution : 0;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
this.maxResolution_ = goog.isDef(options.maxResolution) ?
|
||||
options.maxResolution : Infinity;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {number} resolution Map resolution.
|
||||
* @return {boolean} Does the rule apply to the feature?
|
||||
*/
|
||||
ol.style.Rule.prototype.applies = function(feature, resolution) {
|
||||
var applies = resolution >= this.minResolution_ &&
|
||||
resolution < this.maxResolution_;
|
||||
if (applies && !goog.isNull(this.filter_)) {
|
||||
applies = !!ol.expr.evaluateFeature(this.filter_, feature);
|
||||
}
|
||||
return applies;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {Array.<ol.style.Symbolizer>} Symbolizers.
|
||||
*/
|
||||
ol.style.Rule.prototype.getSymbolizers = function() {
|
||||
return this.symbolizers_;
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
goog.provide('ol.style.ShapeLiteral');
|
||||
goog.provide('ol.style.ShapeType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.PointLiteral');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.style.ShapeType = {
|
||||
CIRCLE: 'circle'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{type: (ol.style.ShapeType),
|
||||
* size: (number),
|
||||
* fillColor: (string|undefined),
|
||||
* fillOpacity: (number|undefined),
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined),
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.ShapeLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.PointLiteral}
|
||||
* @param {ol.style.ShapeLiteralOptions} options Shape literal options.
|
||||
*/
|
||||
ol.style.ShapeLiteral = function(options) {
|
||||
|
||||
goog.asserts.assertString(options.type, 'type must be a string');
|
||||
/** @type {ol.style.ShapeType} */
|
||||
this.type = options.type;
|
||||
|
||||
goog.asserts.assertNumber(options.size, 'size must be a number');
|
||||
/** @type {number} */
|
||||
this.size = options.size;
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.fillColor = options.fillColor;
|
||||
if (goog.isDef(options.fillColor)) {
|
||||
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.fillOpacity = options.fillOpacity;
|
||||
if (goog.isDef(options.fillOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
options.fillOpacity, 'fillOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
if (goog.isDef(this.strokeColor)) {
|
||||
goog.asserts.assertString(
|
||||
this.strokeColor, 'strokeColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
if (goog.isDef(this.strokeOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeOpacity, 'strokeOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
if (goog.isDef(this.strokeWidth)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeWidth, 'strokeWidth must be a number');
|
||||
}
|
||||
|
||||
// fill and/or stroke properties must be defined
|
||||
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
|
||||
var strokeDef = goog.isDef(this.strokeColor) &&
|
||||
goog.isDef(this.strokeOpacity) &&
|
||||
goog.isDef(this.strokeWidth);
|
||||
goog.asserts.assert(fillDef || strokeDef,
|
||||
'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);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
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;
|
||||
};
|
||||
@@ -0,0 +1,241 @@
|
||||
goog.provide('ol.style.Shape');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Point');
|
||||
goog.require('ol.style.ShapeLiteral');
|
||||
goog.require('ol.style.ShapeType');
|
||||
goog.require('ol.style.Stroke');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Point}
|
||||
* @param {ol.style.ShapeOptions} options Shape options.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.style.Shape = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @type {ol.style.ShapeType}
|
||||
* @private
|
||||
*/
|
||||
this.type_ = /** @type {ol.style.ShapeType} */ (goog.isDef(options.type) ?
|
||||
options.type : ol.style.ShapeDefaults.type);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.size_ = !goog.isDefAndNotNull(options.size) ?
|
||||
new ol.expr.Literal(ol.style.ShapeDefaults.size) :
|
||||
(options.size instanceof ol.expr.Expression) ?
|
||||
options.size : new ol.expr.Literal(options.size);
|
||||
|
||||
/**
|
||||
* @type {ol.style.Fill}
|
||||
* @private
|
||||
*/
|
||||
this.fill_ = goog.isDefAndNotNull(options.fill) ? options.fill : null;
|
||||
|
||||
/**
|
||||
* @type {ol.style.Stroke}
|
||||
* @private
|
||||
*/
|
||||
this.stroke_ = goog.isDefAndNotNull(options.stroke) ? options.stroke : null;
|
||||
|
||||
// one of stroke or fill can be null, both null is user error
|
||||
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);
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.Shape, ol.style.Point);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return {ol.style.ShapeLiteral} Literal shape symbolizer.
|
||||
*/
|
||||
ol.style.Shape.prototype.createLiteral = function(featureOrType) {
|
||||
var feature, type;
|
||||
if (featureOrType instanceof ol.Feature) {
|
||||
feature = featureOrType;
|
||||
var geometry = feature.getGeometry();
|
||||
type = geometry ? geometry.getType() : null;
|
||||
} else {
|
||||
type = featureOrType;
|
||||
}
|
||||
|
||||
var literal = null;
|
||||
if (type === ol.geom.GeometryType.POINT ||
|
||||
type === ol.geom.GeometryType.MULTIPOINT) {
|
||||
var size = Number(ol.expr.evaluateFeature(this.size_, feature));
|
||||
goog.asserts.assert(!isNaN(size), 'size must be a number');
|
||||
|
||||
var fillColor, fillOpacity;
|
||||
if (!goog.isNull(this.fill_)) {
|
||||
fillColor = ol.expr.evaluateFeature(this.fill_.getColor(), feature);
|
||||
goog.asserts.assertString(
|
||||
fillColor, 'fillColor must be a string');
|
||||
fillOpacity = Number(ol.expr.evaluateFeature(
|
||||
this.fill_.getOpacity(), feature));
|
||||
goog.asserts.assert(!isNaN(fillOpacity), 'fillOpacity must be a number');
|
||||
}
|
||||
|
||||
var strokeColor, strokeOpacity, strokeWidth;
|
||||
if (!goog.isNull(this.stroke_)) {
|
||||
strokeColor = ol.expr.evaluateFeature(this.stroke_.getColor(), feature);
|
||||
goog.asserts.assertString(
|
||||
strokeColor, 'strokeColor must be a string');
|
||||
strokeOpacity = Number(ol.expr.evaluateFeature(
|
||||
this.stroke_.getOpacity(), feature));
|
||||
goog.asserts.assert(!isNaN(strokeOpacity),
|
||||
'strokeOpacity must be a number');
|
||||
strokeWidth = Number(ol.expr.evaluateFeature(
|
||||
this.stroke_.getWidth(), feature));
|
||||
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,
|
||||
fillColor: fillColor,
|
||||
fillOpacity: fillOpacity,
|
||||
strokeColor: strokeColor,
|
||||
strokeOpacity: strokeOpacity,
|
||||
strokeWidth: strokeWidth,
|
||||
zIndex: zIndex
|
||||
});
|
||||
}
|
||||
|
||||
return literal;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the fill.
|
||||
* @return {ol.style.Fill} Shape fill.
|
||||
*/
|
||||
ol.style.Shape.prototype.getFill = function() {
|
||||
return this.fill_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the shape size.
|
||||
* @return {ol.expr.Expression} Shape size.
|
||||
*/
|
||||
ol.style.Shape.prototype.getSize = function() {
|
||||
return this.size_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the stroke.
|
||||
* @return {ol.style.Stroke} Shape stroke.
|
||||
*/
|
||||
ol.style.Shape.prototype.getStroke = function() {
|
||||
return this.stroke_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the shape type.
|
||||
* @return {ol.style.ShapeType} Shape type.
|
||||
*/
|
||||
ol.style.Shape.prototype.getType = function() {
|
||||
return this.type_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ol.style.Shape.prototype.setFill = function(fill) {
|
||||
if (!goog.isNull(fill)) {
|
||||
goog.asserts.assertInstanceof(fill, ol.style.Fill);
|
||||
}
|
||||
this.fill_ = fill;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the shape size.
|
||||
* @param {ol.expr.Expression} size Shape size.
|
||||
*/
|
||||
ol.style.Shape.prototype.setSize = function(size) {
|
||||
goog.asserts.assertInstanceof(size, ol.expr.Expression);
|
||||
this.size_ = size;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the stroke.
|
||||
* @param {ol.style.Stroke} stroke Shape stroke.
|
||||
*/
|
||||
ol.style.Shape.prototype.setStroke = function(stroke) {
|
||||
if (!goog.isNull(stroke)) {
|
||||
goog.asserts.assertInstanceof(stroke, ol.style.Stroke);
|
||||
}
|
||||
this.stroke_ = stroke;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the shape type.
|
||||
* @param {ol.style.ShapeType} type Shape type.
|
||||
*/
|
||||
ol.style.Shape.prototype.setType = function(type) {
|
||||
this.type_ = type;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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,
|
||||
zIndex: 0
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
goog.provide('ol.style.Stroke');
|
||||
goog.provide('ol.style.StrokeDefaults');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.style.LineLiteral');
|
||||
goog.require('ol.style.PolygonLiteral');
|
||||
goog.require('ol.style.Symbolizer');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Symbolizer}
|
||||
* @param {ol.style.StrokeOptions=} opt_options Stroke options.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.style.Stroke = function(opt_options) {
|
||||
goog.base(this);
|
||||
var options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.color_ = !goog.isDefAndNotNull(options.color) ?
|
||||
new ol.expr.Literal(ol.style.StrokeDefaults.color) :
|
||||
(options.color instanceof ol.expr.Expression) ?
|
||||
options.color : new ol.expr.Literal(options.color);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.opacity_ = !goog.isDefAndNotNull(options.opacity) ?
|
||||
new ol.expr.Literal(ol.style.StrokeDefaults.opacity) :
|
||||
(options.opacity instanceof ol.expr.Expression) ?
|
||||
options.opacity : new ol.expr.Literal(options.opacity);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.width_ = !goog.isDefAndNotNull(options.width) ?
|
||||
new ol.expr.Literal(ol.style.StrokeDefaults.width) :
|
||||
(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);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return {ol.style.LineLiteral|ol.style.PolygonLiteral} Symbolizer literal.
|
||||
*/
|
||||
ol.style.Stroke.prototype.createLiteral = function(featureOrType) {
|
||||
var feature, type;
|
||||
if (featureOrType instanceof ol.Feature) {
|
||||
feature = featureOrType;
|
||||
var geometry = feature.getGeometry();
|
||||
type = geometry ? geometry.getType() : null;
|
||||
} else {
|
||||
type = featureOrType;
|
||||
}
|
||||
|
||||
var color = ol.expr.evaluateFeature(
|
||||
this.color_, feature);
|
||||
goog.asserts.assertString(color, 'color must be a string');
|
||||
|
||||
var opacity = Number(ol.expr.evaluateFeature(
|
||||
this.opacity_, feature));
|
||||
goog.asserts.assert(!isNaN(opacity), 'opacity must be a number');
|
||||
|
||||
var width = Number(ol.expr.evaluateFeature(
|
||||
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,
|
||||
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,
|
||||
zIndex: zIndex
|
||||
});
|
||||
}
|
||||
|
||||
return literal;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the stroke color.
|
||||
* @return {ol.expr.Expression} Stroke color.
|
||||
*/
|
||||
ol.style.Stroke.prototype.getColor = function() {
|
||||
return this.color_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the stroke opacity.
|
||||
* @return {ol.expr.Expression} Stroke opacity.
|
||||
*/
|
||||
ol.style.Stroke.prototype.getOpacity = function() {
|
||||
return this.opacity_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the stroke width.
|
||||
* @return {ol.expr.Expression} Stroke width.
|
||||
*/
|
||||
ol.style.Stroke.prototype.getWidth = function() {
|
||||
return this.width_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ol.style.Stroke.prototype.setColor = function(color) {
|
||||
goog.asserts.assertInstanceof(color, ol.expr.Expression);
|
||||
this.color_ = color;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the stroke opacity.
|
||||
* @param {ol.expr.Expression} opacity Stroke opacity.
|
||||
*/
|
||||
ol.style.Stroke.prototype.setOpacity = function(opacity) {
|
||||
goog.asserts.assertInstanceof(opacity, ol.expr.Expression);
|
||||
this.opacity_ = opacity;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the stroke width.
|
||||
* @param {ol.expr.Expression} width Stroke width.
|
||||
*/
|
||||
ol.style.Stroke.prototype.setWidth = function(width) {
|
||||
goog.asserts.assertInstanceof(width, ol.expr.Expression);
|
||||
this.width_ = width;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the stroke zIndex.
|
||||
* @param {ol.expr.Expression} zIndex Stroke zIndex.
|
||||
*/
|
||||
ol.style.Stroke.prototype.setZIndex = function(zIndex) {
|
||||
goog.asserts.assertInstanceof(zIndex, ol.expr.Expression);
|
||||
this.zIndex_ = zIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{strokeColor: string,
|
||||
* strokeOpacity: number,
|
||||
* strokeWidth: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.StrokeDefaults = {
|
||||
color: '#696969',
|
||||
opacity: 0.75,
|
||||
width: 1.5,
|
||||
zIndex: 0
|
||||
};
|
||||
@@ -0,0 +1,209 @@
|
||||
goog.provide('ol.style');
|
||||
goog.provide('ol.style.Style');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr.Call');
|
||||
goog.require('ol.expr.Identifier');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.expr.functions');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.style.Fill');
|
||||
goog.require('ol.style.Literal');
|
||||
goog.require('ol.style.PolygonLiteral');
|
||||
goog.require('ol.style.Rule');
|
||||
goog.require('ol.style.Shape');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.style.Symbolizer');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {ol.style.StyleOptions} options Style options.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.style.Style = function(options) {
|
||||
|
||||
/**
|
||||
* @type {Array.<ol.style.Rule>}
|
||||
* @private
|
||||
*/
|
||||
this.rules_ = goog.isDef(options.rules) ? options.rules : [];
|
||||
|
||||
/**
|
||||
* Symbolizers that apply if no rules are given or where none of the given
|
||||
* rules apply (these are the "else" symbolizers).
|
||||
* @type {Array.<ol.style.Symbolizer>}
|
||||
* @private
|
||||
*/
|
||||
this.symbolizers_ = goog.isDef(options.symbolizers) ?
|
||||
options.symbolizers : [];
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create an array of symbolizer literals for a feature.
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {number} resolution Map resolution.
|
||||
* @return {Array.<ol.style.Literal>} Symbolizer literals for the
|
||||
* feature.
|
||||
*/
|
||||
ol.style.Style.prototype.createLiterals = function(feature, resolution) {
|
||||
var rules = this.rules_,
|
||||
symbolizers = [],
|
||||
applies = false,
|
||||
rule;
|
||||
for (var i = 0, ii = rules.length; i < ii; ++i) {
|
||||
rule = rules[i];
|
||||
if (rule.applies(feature, resolution)) {
|
||||
applies = true;
|
||||
symbolizers.push.apply(symbolizers, rule.getSymbolizers());
|
||||
}
|
||||
} if (!applies) {
|
||||
// these are the "else" symbolizers
|
||||
symbolizers = this.symbolizers_;
|
||||
}
|
||||
return ol.style.Style.createLiterals(symbolizers, feature);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The default style.
|
||||
* @type {ol.style.Style}
|
||||
* @private
|
||||
*/
|
||||
ol.style.default_ = null;
|
||||
|
||||
|
||||
/**
|
||||
* Get the default style.
|
||||
* @return {ol.style.Style} The default style.
|
||||
*/
|
||||
ol.style.getDefault = function() {
|
||||
if (goog.isNull(ol.style.default_)) {
|
||||
ol.style.default_ = new ol.style.Style({
|
||||
rules: [
|
||||
new ol.style.Rule({
|
||||
filter: new ol.expr.Call(
|
||||
new ol.expr.Identifier(ol.expr.functions.RENDER_INTENT),
|
||||
[new ol.expr.Literal('select')]),
|
||||
symbolizers: [
|
||||
new ol.style.Shape({
|
||||
fill: new ol.style.Fill({
|
||||
color: '#ffffff',
|
||||
opacity: 0.7
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#696969',
|
||||
opacity: 0.9,
|
||||
width: 2.0
|
||||
})
|
||||
}),
|
||||
new ol.style.Fill({
|
||||
color: '#ffffff',
|
||||
opacity: 0.7
|
||||
}),
|
||||
new ol.style.Stroke({
|
||||
color: '#696969',
|
||||
opacity: 0.9,
|
||||
width: 2.0
|
||||
})
|
||||
]
|
||||
})
|
||||
],
|
||||
symbolizers: [
|
||||
new ol.style.Shape({
|
||||
fill: new ol.style.Fill(),
|
||||
stroke: new ol.style.Stroke()
|
||||
}),
|
||||
new ol.style.Fill(),
|
||||
new ol.style.Stroke()
|
||||
]
|
||||
});
|
||||
}
|
||||
return ol.style.default_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the default style.
|
||||
* @param {ol.style.Style} style The new default style.
|
||||
* @return {ol.style.Style} The default style.
|
||||
*/
|
||||
ol.style.setDefault = function(style) {
|
||||
ol.style.default_ = style;
|
||||
return style;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Given an array of symbolizers, generate an array of literals.
|
||||
* @param {Array.<ol.style.Symbolizer>} symbolizers List of symbolizers.
|
||||
* @param {ol.Feature|ol.geom.GeometryType} featureOrType Feature or geometry
|
||||
* type.
|
||||
* @return {Array.<ol.style.Literal>} Array of literals.
|
||||
*/
|
||||
ol.style.Style.createLiterals = function(symbolizers, featureOrType) {
|
||||
var length = symbolizers.length;
|
||||
var literals = new Array(length);
|
||||
for (var i = 0; i < length; ++i) {
|
||||
literals[i] = symbolizers[i].createLiteral(featureOrType);
|
||||
}
|
||||
return ol.style.Style.reduceLiterals_(literals);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Collapse partial polygon symbolizers and remove null symbolizers.
|
||||
* @param {Array.<ol.style.Literal>} literals Input literals.
|
||||
* @return {Array.<ol.style.Literal>} Reduced literals.
|
||||
* @private
|
||||
*/
|
||||
ol.style.Style.reduceLiterals_ = function(literals) {
|
||||
var reduced = [];
|
||||
var literal, stroke, fill, key, value;
|
||||
for (var i = 0, ii = literals.length; i < ii; ++i) {
|
||||
literal = literals[i];
|
||||
if (literal instanceof ol.style.PolygonLiteral) {
|
||||
if (goog.isDef(literal.strokeColor) &&
|
||||
!goog.isDef(literal.fillColor)) {
|
||||
// stroke only, check for previous fill only
|
||||
if (fill) {
|
||||
for (key in literal) {
|
||||
value = literal[key];
|
||||
if (goog.isDef(value)) {
|
||||
fill[key] = value;
|
||||
}
|
||||
}
|
||||
fill = null;
|
||||
} else {
|
||||
stroke = literal;
|
||||
reduced.push(stroke);
|
||||
}
|
||||
} else if (goog.isDef(literal.fillColor) &&
|
||||
!goog.isDef(literal.strokeColor)) {
|
||||
// fill only, check for previous stroke only
|
||||
if (stroke) {
|
||||
for (key in literal) {
|
||||
value = literal[key];
|
||||
if (goog.isDef(value)) {
|
||||
stroke[key] = value;
|
||||
}
|
||||
}
|
||||
stroke = null;
|
||||
} else {
|
||||
fill = literal;
|
||||
reduced.push(fill);
|
||||
}
|
||||
} else {
|
||||
// both stroke and fill, proceed
|
||||
reduced.push(literal);
|
||||
}
|
||||
} else if (literal) {
|
||||
reduced.push(literal);
|
||||
}
|
||||
}
|
||||
return reduced;
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
goog.provide('ol.style.Symbolizer');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
ol.style.Symbolizer = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* Create a literal from the symbolizer given a complete feature or a geometry
|
||||
* type.
|
||||
* @param {ol.geom.GeometryType|ol.Feature} featureOrType Feature for evaluating
|
||||
* expressions or a geometry type.
|
||||
* @return {ol.style.Literal} Literal symbolizer.
|
||||
*/
|
||||
ol.style.Symbolizer.prototype.createLiteral = goog.abstractMethod;
|
||||
@@ -0,0 +1,106 @@
|
||||
goog.provide('ol.style.TextLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: string,
|
||||
* fontFamily: string,
|
||||
* fontSize: number,
|
||||
* fontWeight: string,
|
||||
* text: string,
|
||||
* opacity: number,
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined),
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.TextLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.TextLiteralOptions} options Text literal options.
|
||||
*/
|
||||
ol.style.TextLiteral = function(options) {
|
||||
|
||||
goog.asserts.assertString(options.color, 'color must be a string');
|
||||
/** @type {string} */
|
||||
this.color = options.color;
|
||||
|
||||
goog.asserts.assertString(options.fontFamily, 'fontFamily must be a string');
|
||||
/** @type {string} */
|
||||
this.fontFamily = options.fontFamily;
|
||||
|
||||
goog.asserts.assertNumber(options.fontSize, 'fontSize must be a number');
|
||||
/** @type {number} */
|
||||
this.fontSize = options.fontSize;
|
||||
|
||||
goog.asserts.assertString(options.fontWeight, 'fontWeight must be a string');
|
||||
/** @type {string} */
|
||||
this.fontWeight = options.fontWeight;
|
||||
|
||||
goog.asserts.assertString(options.text, 'text must be a string');
|
||||
/** @type {string} */
|
||||
this.text = options.text;
|
||||
|
||||
goog.asserts.assertNumber(options.opacity, 'opacity must be a number');
|
||||
/** @type {number} */
|
||||
this.opacity = options.opacity;
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
if (goog.isDef(this.strokeColor)) {
|
||||
goog.asserts.assertString(
|
||||
this.strokeColor, 'strokeColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
if (goog.isDef(this.strokeOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeOpacity, 'strokeOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
if (goog.isDef(this.strokeWidth)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeWidth, 'strokeWidth must be a number');
|
||||
}
|
||||
|
||||
// if any stroke property is defined, all must be defined
|
||||
var strokeDef = goog.isDef(this.strokeColor) &&
|
||||
goog.isDef(this.strokeOpacity) &&
|
||||
goog.isDef(this.strokeWidth);
|
||||
var strokeUndef = !goog.isDef(this.strokeColor) &&
|
||||
!goog.isDef(this.strokeOpacity) &&
|
||||
!goog.isDef(this.strokeWidth);
|
||||
goog.asserts.assert(strokeDef || strokeUndef,
|
||||
'If any stroke property is defined, all must be defined');
|
||||
|
||||
goog.asserts.assertNumber(options.zIndex, 'zIndex must be a number');
|
||||
/** @type {number} */
|
||||
this.zIndex = options.zIndex;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.TextLiteral, ol.style.Literal);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.TextLiteral.prototype.equals = function(other) {
|
||||
return this.color == other.color &&
|
||||
this.fontFamily == other.fontFamily &&
|
||||
this.fontSize == other.fontSize &&
|
||||
this.fontWeight == other.fontWeight &&
|
||||
this.opacity == other.opacity &&
|
||||
this.strokeColor == other.strokeColor &&
|
||||
this.strokeOpacity == other.strokeOpacity &&
|
||||
this.strokeWidth == other.strokeWidth &&
|
||||
this.zIndex == other.zIndex;
|
||||
};
|
||||
@@ -0,0 +1,303 @@
|
||||
goog.provide('ol.style.Text');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.Symbolizer');
|
||||
goog.require('ol.style.TextLiteral');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Symbolizer}
|
||||
* @param {ol.style.TextOptions} options Text options.
|
||||
*/
|
||||
ol.style.Text = function(options) {
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.color_ = !goog.isDef(options.color) ?
|
||||
new ol.expr.Literal(ol.style.TextDefaults.color) :
|
||||
(options.color instanceof ol.expr.Expression) ?
|
||||
options.color : new ol.expr.Literal(options.color);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.fontFamily_ = !goog.isDef(options.fontFamily) ?
|
||||
new ol.expr.Literal(ol.style.TextDefaults.fontFamily) :
|
||||
(options.fontFamily instanceof ol.expr.Expression) ?
|
||||
options.fontFamily : new ol.expr.Literal(options.fontFamily);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.fontSize_ = !goog.isDef(options.fontSize) ?
|
||||
new ol.expr.Literal(ol.style.TextDefaults.fontSize) :
|
||||
(options.fontSize instanceof ol.expr.Expression) ?
|
||||
options.fontSize : new ol.expr.Literal(options.fontSize);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.fontWeight_ = !goog.isDef(options.fontWeight) ?
|
||||
new ol.expr.Literal(ol.style.TextDefaults.fontWeight) :
|
||||
(options.fontWeight instanceof ol.expr.Expression) ?
|
||||
options.fontWeight : new ol.expr.Literal(options.fontWeight);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.text_ = (options.text instanceof ol.expr.Expression) ?
|
||||
options.text : new ol.expr.Literal(options.text);
|
||||
|
||||
/**
|
||||
* @type {ol.expr.Expression}
|
||||
* @private
|
||||
*/
|
||||
this.opacity_ = !goog.isDef(options.opacity) ?
|
||||
new ol.expr.Literal(ol.style.TextDefaults.opacity) :
|
||||
(options.opacity instanceof ol.expr.Expression) ?
|
||||
options.opacity : new ol.expr.Literal(options.opacity);
|
||||
|
||||
/**
|
||||
* @type {ol.style.Stroke}
|
||||
* @private
|
||||
*/
|
||||
this.stroke_ = goog.isDefAndNotNull(options.stroke) ? options.stroke : null;
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @return {ol.style.TextLiteral} Literal text symbolizer.
|
||||
*/
|
||||
ol.style.Text.prototype.createLiteral = function(featureOrType) {
|
||||
var feature, type;
|
||||
if (featureOrType instanceof ol.Feature) {
|
||||
feature = featureOrType;
|
||||
var geometry = feature.getGeometry();
|
||||
type = geometry ? geometry.getType() : null;
|
||||
} else {
|
||||
type = featureOrType;
|
||||
}
|
||||
|
||||
var color = ol.expr.evaluateFeature(this.color_, feature);
|
||||
goog.asserts.assertString(color, 'color must be a string');
|
||||
|
||||
var fontFamily = ol.expr.evaluateFeature(this.fontFamily_, feature);
|
||||
goog.asserts.assertString(fontFamily, 'fontFamily must be a string');
|
||||
|
||||
var fontSize = Number(ol.expr.evaluateFeature(this.fontSize_, feature));
|
||||
goog.asserts.assert(!isNaN(fontSize), 'fontSize must be a number');
|
||||
|
||||
var fontWeight = ol.expr.evaluateFeature(this.fontWeight_, feature);
|
||||
goog.asserts.assertString(fontWeight, 'fontWeight must be a string');
|
||||
|
||||
var text = ol.expr.evaluateFeature(this.text_, feature);
|
||||
goog.asserts.assertString(text, 'text must be a string');
|
||||
|
||||
var opacity = Number(ol.expr.evaluateFeature(this.opacity_, feature));
|
||||
goog.asserts.assert(!isNaN(opacity), 'opacity must be a number');
|
||||
|
||||
var strokeColor, strokeOpacity, strokeWidth;
|
||||
if (!goog.isNull(this.stroke_)) {
|
||||
strokeColor = ol.expr.evaluateFeature(this.stroke_.getColor(), feature);
|
||||
goog.asserts.assertString(
|
||||
strokeColor, 'strokeColor must be a string');
|
||||
strokeOpacity = Number(ol.expr.evaluateFeature(
|
||||
this.stroke_.getOpacity(), feature));
|
||||
goog.asserts.assert(!isNaN(strokeOpacity),
|
||||
'strokeOpacity must be a number');
|
||||
strokeWidth = Number(ol.expr.evaluateFeature(
|
||||
this.stroke_.getWidth(), feature));
|
||||
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');
|
||||
|
||||
return new ol.style.TextLiteral({
|
||||
color: color,
|
||||
fontFamily: fontFamily,
|
||||
fontSize: fontSize,
|
||||
fontWeight: fontWeight,
|
||||
text: text,
|
||||
opacity: opacity,
|
||||
strokeColor: strokeColor,
|
||||
strokeOpacity: strokeOpacity,
|
||||
strokeWidth: strokeWidth,
|
||||
zIndex: zIndex
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the font color.
|
||||
* @return {ol.expr.Expression} Font color.
|
||||
*/
|
||||
ol.style.Text.prototype.getColor = function() {
|
||||
return this.color_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the font family.
|
||||
* @return {ol.expr.Expression} Font family.
|
||||
*/
|
||||
ol.style.Text.prototype.getFontFamily = function() {
|
||||
return this.fontFamily_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the font size.
|
||||
* @return {ol.expr.Expression} Font size.
|
||||
*/
|
||||
ol.style.Text.prototype.getFontSize = function() {
|
||||
return this.fontSize_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the font weight.
|
||||
* @return {ol.expr.Expression} Font weight.
|
||||
*/
|
||||
ol.style.Text.prototype.getFontWeight = function() {
|
||||
return this.fontWeight_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the opacity.
|
||||
* @return {ol.expr.Expression} Opacity.
|
||||
*/
|
||||
ol.style.Text.prototype.getOpacity = function() {
|
||||
return this.opacity_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the text.
|
||||
* @return {ol.expr.Expression} Text.
|
||||
*/
|
||||
ol.style.Text.prototype.getText = function() {
|
||||
return this.text_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ol.style.Text.prototype.setColor = function(color) {
|
||||
goog.asserts.assertInstanceof(color, ol.expr.Expression);
|
||||
this.color_ = color;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the font family.
|
||||
* @param {ol.expr.Expression} fontFamily Font family.
|
||||
*/
|
||||
ol.style.Text.prototype.setFontFamily = function(fontFamily) {
|
||||
goog.asserts.assertInstanceof(fontFamily, ol.expr.Expression);
|
||||
this.fontFamily_ = fontFamily;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the font size.
|
||||
* @param {ol.expr.Expression} fontSize Font size.
|
||||
*/
|
||||
ol.style.Text.prototype.setFontSize = function(fontSize) {
|
||||
goog.asserts.assertInstanceof(fontSize, ol.expr.Expression);
|
||||
this.fontSize_ = fontSize;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the font weight.
|
||||
* @param {ol.expr.Expression} fontWeight Font weight.
|
||||
*/
|
||||
ol.style.Text.prototype.setFontWeight = function(fontWeight) {
|
||||
goog.asserts.assertInstanceof(fontWeight, ol.expr.Expression);
|
||||
this.fontWeight_ = fontWeight;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the opacity.
|
||||
* @param {ol.expr.Expression} opacity Opacity.
|
||||
*/
|
||||
ol.style.Text.prototype.setOpacity = function(opacity) {
|
||||
goog.asserts.assertInstanceof(opacity, ol.expr.Expression);
|
||||
this.opacity_ = opacity;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the text.
|
||||
* @param {ol.expr.Expression} text Text.
|
||||
*/
|
||||
ol.style.Text.prototype.setText = function(text) {
|
||||
goog.asserts.assertInstanceof(text, ol.expr.Expression);
|
||||
this.text_ = 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,
|
||||
* fontWeight: string,
|
||||
* opacity: number,
|
||||
* zIndex: number}}
|
||||
*/
|
||||
ol.style.TextDefaults = {
|
||||
color: '#000',
|
||||
fontFamily: 'sans-serif',
|
||||
fontSize: 10,
|
||||
fontWeight: 'normal',
|
||||
opacity: 1,
|
||||
zIndex: 0
|
||||
};
|
||||
Reference in New Issue
Block a user