I'm building an application which use this javascript plugin to upload a ZIP file and convert the shapefile in it to GeoJSON, so that it can be added to a map.
My application use ExtJS 6.0 and I can't seem to find how to use the "filefield" button to give the path of the zipped file to the plugin. The problem is that the filefield gives only a fakepath (I think it's for some kind of user-protection). Therefore, I can't use the path given by my form as input for the plugin (I'm getting a 404 error because it use C:\fakepath\file.zip as input). If I give manually the path, everything works fine....
Here's the code of my function:
var getShp = function getShp(){
Ext.create('Ext.window.Window', {
title: 'Upload new ESRI shapefile',
width: 400,
items: {
xtype: 'form',
id: 'urlFormId',
items: [{
xtype: 'filefield',
name: 'shp',
fieldLabel: 'Shapefile (*.shp)',
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select shapefile...'
}],
buttons: [{
text: 'Add layer',
handler: function() {
var form = Ext.getCmp('urlFormId').getForm();
var shpUrl = form.findField('shp').getValue();
var vectorSource = new ol.source.Vector();
loadshp({
url: shpUrl,
encoding: 'UTF-9',
EPSG: '4326'
}, function(data) {
shpUp = new ol.layer.Vector({
name: 'Test world',
source: new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(data)
})
})
olMap.addLayer(shpUp);
});
}
}]
}
}).show();
}