可以按照 Openlayers 3 演示页面上的说明实现拖放矢量图层:
http://openlayers.org/en/v3.15.1/examples/drag-and-drop.html
这工作得很好,所以我不会在这里发布源代码。
我的问题是:如何获取要添加到 map 中的文件名(或图层名称)? API 文档 here 中没有什么对我来说很突出的.
最佳答案
我已经弄清楚了,据我所知,它并不存在于 API 文档中,但通过 Firebug,我能够从 DragAndDropInteraction 事件处理程序中获取该值:
dragAndDropInteraction.on('addfeatures', function(event) {
var file_name = event.file.name;
});
关于javascript - 打开Layers 3拖放功能,获取拖放文件的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36749994/