Common code for creating a style function

This commit is contained in:
Tim Schaub
2014-02-07 13:25:21 -07:00
parent 6abb691224
commit c64c24d3dc
5 changed files with 72 additions and 82 deletions

View File

@@ -1,9 +1,7 @@
goog.provide('ol.layer.Vector');
goog.require('goog.asserts');
goog.require('ol.feature');
goog.require('ol.layer.Layer');
goog.require('ol.style.Style');
/**
@@ -30,31 +28,7 @@ ol.layer.Vector = function(opt_options) {
goog.base(this, /** @type {olx.layer.LayerOptions} */ (options));
if (goog.isDef(options.style)) {
/**
* @type {ol.feature.StyleFunction}
*/
var styleFunction;
if (goog.isFunction(options.style)) {
styleFunction = /** @type {ol.feature.StyleFunction} */ (options.style);
} else {
/**
* @type {Array.<ol.style.Style>}
*/
var styles;
if (goog.isArray(options.style)) {
styles = options.style;
} else {
goog.asserts.assertInstanceof(options.style, ol.style.Style);
styles = [options.style];
}
styleFunction = function(feature, resolution) {
return styles;
};
}
this.setStyleFunction(styleFunction);
this.setStyleFunction(ol.feature.createStyleFunction(options.style));
}
};