diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 8dc27ba5d6..88c4cca834 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -503,6 +503,13 @@ * supported. */ +/** + * @typedef {Object} olx.render.FeaturesOverlayOptions + * @property {Array.|ol.Collection|undefined} features Features. + * @property {ol.Map|undefined} map Map. + * @property {ol.style.StyleFunction|undefined} styleFunction Style function. + */ + /** * @typedef {Object} olx.source.BingMapsOptions * @property {string|undefined} culture Culture code. Default is `en-us`. diff --git a/src/ol/render/featuresoverlay.js b/src/ol/render/featuresoverlay.js index 3b5352c784..914cad6dfc 100644 --- a/src/ol/render/featuresoverlay.js +++ b/src/ol/render/featuresoverlay.js @@ -15,8 +15,11 @@ goog.require('ol.style.StyleFunction'); /** * @constructor + * @param {olx.render.FeaturesOverlayOptions=} opt_options Options. */ -ol.render.FeaturesOverlay = function() { +ol.render.FeaturesOverlay = function(opt_options) { + + var options = goog.isDef(opt_options) ? opt_options : options; /** * @private @@ -54,6 +57,23 @@ ol.render.FeaturesOverlay = function() { */ this.styleFunction_ = undefined; + if (goog.isDef(options.features)) { + if (goog.isArray(options.features)) { + this.setFeatures(new ol.Collection(goog.array.clone(options.features))); + } else { + goog.asserts.assertInstanceof(options.features, ol.Collection); + this.setFeatures(options.features); + } + } + + if (goog.isDef(options.styleFunction)) { + this.setStyleFunction(options.styleFunction); + } + + if (goog.isDef(options.map)) { + this.setMap(options.map); + } + };