Don't create unnecessary closure in constructor
This commit is contained in:
@@ -50,32 +50,26 @@ ol.source.StaticVector = function(options) {
|
|||||||
if (goog.isDef(options.url) || goog.isDef(options.urls)) {
|
if (goog.isDef(options.url) || goog.isDef(options.urls)) {
|
||||||
this.setState(ol.source.State.LOADING);
|
this.setState(ol.source.State.LOADING);
|
||||||
if (goog.isDef(options.url)) {
|
if (goog.isDef(options.url)) {
|
||||||
this.loadFeaturesFromURL(options.url,
|
this.loadFeaturesFromURL(options.url, this.onFeaturesLoaded_, this);
|
||||||
/**
|
|
||||||
* @param {Array.<ol.Feature>} features Features.
|
|
||||||
* @this {ol.source.StaticVector}
|
|
||||||
*/
|
|
||||||
function(features) {
|
|
||||||
this.addFeaturesInternal(features);
|
|
||||||
this.setState(ol.source.State.READY);
|
|
||||||
}, this);
|
|
||||||
}
|
}
|
||||||
if (goog.isDef(options.urls)) {
|
if (goog.isDef(options.urls)) {
|
||||||
var urls = options.urls;
|
var urls = options.urls;
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = urls.length; i < ii; ++i) {
|
for (i = 0, ii = urls.length; i < ii; ++i) {
|
||||||
this.loadFeaturesFromURL(urls[i],
|
this.loadFeaturesFromURL(urls[i], this.onFeaturesLoaded_, this);
|
||||||
/**
|
|
||||||
* @param {Array.<ol.Feature>} features Features.
|
|
||||||
* @this {ol.source.StaticVector}
|
|
||||||
*/
|
|
||||||
function(features) {
|
|
||||||
this.addFeaturesInternal(features);
|
|
||||||
this.setState(ol.source.State.READY);
|
|
||||||
}, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.source.StaticVector, ol.source.FormatVector);
|
goog.inherits(ol.source.StaticVector, ol.source.FormatVector);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array.<ol.Feature>} features Features.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.source.StaticVector.prototype.onFeaturesLoaded_ = function(features) {
|
||||||
|
this.addFeaturesInternal(features);
|
||||||
|
this.setState(ol.source.State.READY);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user