Add options object to ol.render.FeaturesOverlay constructor
This commit is contained in:
@@ -503,6 +503,13 @@
|
||||
* supported.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} olx.render.FeaturesOverlayOptions
|
||||
* @property {Array.<ol.Feature>|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`.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user