Give feature overlays a style option

This commit is contained in:
Tim Schaub
2014-02-07 12:52:41 -07:00
parent b309c44020
commit 6abb691224
6 changed files with 51 additions and 40 deletions

View File

@@ -10,6 +10,7 @@ goog.require('ol.CollectionEventType');
goog.require('ol.Feature');
goog.require('ol.feature');
goog.require('ol.render.EventType');
goog.require('ol.style.Style');
@@ -52,11 +53,35 @@ ol.FeatureOverlay = function(opt_options) {
*/
this.postComposeListenerKey_ = null;
/**
* @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|undefined}
*/
this.styleFunction_ = undefined;
this.styleFunction_ = styleFunction;
if (goog.isDef(options.features)) {
if (goog.isArray(options.features)) {
@@ -69,10 +94,6 @@ ol.FeatureOverlay = function(opt_options) {
this.setFeatures(new ol.Collection());
}
if (goog.isDef(options.styleFunction)) {
this.setStyleFunction(options.styleFunction);
}
if (goog.isDef(options.map)) {
this.setMap(options.map);
}