Allow drag and drop interaction to be configured with a source

This commit is contained in:
Tim Schaub
2017-08-10 07:10:13 -06:00
parent 23405b80a2
commit 17b6088a79
3 changed files with 67 additions and 1 deletions

View File

@@ -49,6 +49,12 @@ ol.interaction.DragAndDrop = function(opt_options) {
*/
this.dropListenKeys_ = null;
/**
* @private
* @type {ol.source.Vector}
*/
this.source_ = options.source || null;
/**
* @private
* @type {Element}
@@ -122,6 +128,10 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, event) {
break;
}
}
if (this.source_) {
this.source_.clear();
this.source_.addFeatures(features);
}
this.dispatchEvent(
new ol.interaction.DragAndDrop.Event(
ol.interaction.DragAndDrop.EventType_.ADD_FEATURES, file,