Merge pull request #1433 from twpayne/vector-api-export-featuresoverlay

[vector-api] Export ol.render.FeaturesOverlay
This commit is contained in:
Éric Lemoine
2014-01-07 04:46:04 -08:00
3 changed files with 33 additions and 1 deletions

View File

@@ -505,6 +505,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`.

View File

@@ -0,0 +1,5 @@
@exportSymbol ol.render.FeaturesOverlay
@exportProperty ol.render.FeaturesOverlay.prototype.getFeatures
@exportProperty ol.render.FeaturesOverlay.prototype.setFeatures
@exportProperty ol.render.FeaturesOverlay.prototype.setMap
@exportProperty ol.render.FeaturesOverlay.prototype.setStyleFunction

View File

@@ -15,8 +15,11 @@ goog.require('ol.render.EventType');
/**
* @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);
}
};