简体   繁体   English

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

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

Dragging and dropping vector layers can be achieved as per the instructions on the Openlayers 3 demo page: 可以根据Openlayers 3演示页面上的说明实现拖放矢量图层:

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

This works perfectly fine, so I shan't post the source code here. 这非常好用,所以我不会在这里发布源代码。

My question is: How can I get the file name (or layer name) that's being added to the map? 我的问题是:如何获取要添加到地图中的文件名(或图层名称)? Nothing stands out to me in the API documentation here . 这里的API文档中没有什么是突出的。

I've sussed it out, it isn't present in the API docs as far as I can tell, but via Firebug I was able to get the value from within the dragAndDropInteraction event handler: 我已经把它搞砸了,据我所知,它在API文档中没有出现,但是通过Firebug,我能够从dragAndDropInteraction事件处理程序中获取值:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM