Separate out feature reading and feature adding
This commit is contained in:
@@ -23,35 +23,51 @@ ol.source.StaticVector = function(options) {
|
||||
});
|
||||
|
||||
if (goog.isDef(options.arrayBuffer)) {
|
||||
this.readFeatures(options.arrayBuffer);
|
||||
this.addFeaturesInternal(this.readFeatures(options.arrayBuffer));
|
||||
}
|
||||
|
||||
if (goog.isDef(options.doc)) {
|
||||
this.readFeatures(options.doc);
|
||||
this.addFeaturesInternal(this.readFeatures(options.doc));
|
||||
}
|
||||
|
||||
if (goog.isDef(options.node)) {
|
||||
this.readFeatures(options.node);
|
||||
this.addFeaturesInternal(this.readFeatures(options.node));
|
||||
}
|
||||
|
||||
if (goog.isDef(options.object)) {
|
||||
this.readFeatures(options.object);
|
||||
this.addFeaturesInternal(this.readFeatures(options.object));
|
||||
}
|
||||
|
||||
if (goog.isDef(options.text)) {
|
||||
this.readFeatures(options.text);
|
||||
this.addFeaturesInternal(this.readFeatures(options.text));
|
||||
}
|
||||
|
||||
if (goog.isDef(options.url) || goog.isDef(options.urls)) {
|
||||
this.setState(ol.source.State.LOADING);
|
||||
if (goog.isDef(options.url)) {
|
||||
this.loadFeaturesFromURL(options.url);
|
||||
this.loadFeaturesFromURL(options.url,
|
||||
/**
|
||||
* @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)) {
|
||||
var urls = options.urls;
|
||||
var i, ii;
|
||||
for (i = 0, ii = urls.length; i < ii; ++i) {
|
||||
this.loadFeaturesFromURL(urls[i]);
|
||||
this.loadFeaturesFromURL(urls[i],
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @this {ol.source.StaticVector}
|
||||
*/
|
||||
function(features) {
|
||||
this.addFeaturesInternal(features);
|
||||
this.setState(ol.source.State.READY);
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user