Give vector image source a style option

This commit is contained in:
Tim Schaub
2014-02-07 12:32:42 -07:00
parent 1072f6dfa7
commit b309c44020
4 changed files with 41 additions and 18 deletions

View File

@@ -12,6 +12,7 @@ goog.require('ol.render.canvas.ReplayGroup');
goog.require('ol.renderer.vector');
goog.require('ol.source.ImageCanvas');
goog.require('ol.source.Vector');
goog.require('ol.style.Style');
goog.require('ol.vec.Mat4');
@@ -40,12 +41,38 @@ ol.source.ImageVector = function(options) {
*/
this.source_ = options.source;
/**
* @type {ol.feature.StyleFunction}
*/
var styleFunction;
if (goog.isDef(options.style)) {
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;
};
}
}
/**
* @private
* @type {!ol.feature.StyleFunction}
*/
this.styleFunction_ = goog.isDef(options.styleFunction) ?
options.styleFunction : ol.feature.defaultStyleFunction;
this.styleFunction_ = goog.isDef(styleFunction) ?
styleFunction : ol.feature.defaultStyleFunction;
/**
* @private