打开 Layers 3 拖放功能,获取拖放文件的文件名

Open Layers 3 Drag & Drop feature, get file name of file dropped

可以按照 Openlayers 3 演示页面上的说明实现拖放矢量图层:

http://openlayers.org/en/v3.15.1/examples/drag-and-drop.html

这工作得很好,所以我不会post这里的源代码。

我的问题是:如何获取要添加到地图的文件名(或图层名)? API 文档 here.

中没有什么特别之处

我已经猜到了,据我所知 API 文档中没有它,但是通过 Firebug 我能够从 dragAndDropInteraction 中获取值事件处理程序:

dragAndDropInteraction.on('addfeatures', function(event) {    
     var file_name = event.file.name;
});