Single Entity
Single Entity

Reputation: 3115

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:

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.

Upvotes: 1

Views: 439

Answers (1)

Single Entity
Single Entity

Reputation: 3115

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:

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

Upvotes: 0

Related Questions