Add ol.layer.Vector

This commit is contained in:
Tom Payne
2013-11-07 15:04:53 +01:00
parent 30311f0b65
commit 711917db62
2 changed files with 83 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
goog.provide('ol.layer.Vector');
goog.require('ol.layer.Layer');
goog.require('ol.source.Vector');
/**
* @enum {string}
*/
ol.layer.VectorProperty = {
STYLE_FUNCTION: 'styleFunction'
};
/**
* @constructor
* @extends {ol.layer.Layer}
* @param {ol.layer.VectorOptions=} opt_options Options.
*/
ol.layer.Vector = function(opt_options) {
var options = goog.isDef(opt_options) ?
opt_options : /** @type {ol.layer.VectorOptions} */ ({});
goog.base(this, /** @type {ol.layer.LayerOptions} */ (options));
// FIXME veryify this
if (goog.isDef(options.styleFunction)) {
this.setStyleFunction(options.styleFunction);
}
};
goog.inherits(ol.layer.Vector, ol.layer.Layer);
/**
* @return {ol.style.StyleFunction|undefined} Style function.
*/
ol.layer.Vector.prototype.getStyleFunction = function() {
return /** @type {ol.style.StyleFunction|undefined} */ (
this.get(ol.layer.VectorProperty.STYLE_FUNCTION));
};
goog.exportProperty(
ol.layer.Vector.prototype,
'getStyleFunction',
ol.layer.Vector.prototype.getStyleFunction);
/**
* @return {ol.source.Source} Vector source.
*/
ol.layer.Vector.prototype.getVectorSource = function() {
return /** @type {ol.source.Vector} */ (this.getSource());
};
/**
* @param {ol.style.StyleFunction|undefined} styleFunction Style function.
*/
ol.layer.Vector.prototype.setStyleFunction = function(styleFunction) {
this.set(ol.layer.VectorProperty.STYLE_FUNCTION, styleFunction);
};
goog.exportProperty(
ol.layer.Vector.prototype,
'setStyleFunction',
ol.layer.Vector.prototype.setStyleFunction);