In am writing JavaScript
code for adding kmz,kml and csv file from local folder.All the files will be displayed/added on esri Maps.I am able to add kml and csv, but not kmz.I dont want to include full zip/unzip code or library into my code.I dont need that all.Only need a small code for converting kmz to kml.
Also I don't want to store any unzipped or converted file(which will be kml) in any local folder.
Just want to read the contents and pass it to my add_kml() function on the fly. Only want to extract the contents from kmz file which will be kml. The code available everywhere is to store the extracted file in some folder.I dont want that.
function unZipAndProcessKMZ(blob) {
zip.createReader(new zip.BlobReader(blob),
function(reader) {// get all entries from the zip reader.getEntries( function(entries) { parseTransformKMZ(entries);} ); }, function(error) {/* onerror callback */ } ); }
function parseTransformKMZ(entries)
{
//Step 1: find doc.kml
var docKMLentry = findFileByName(entries, '.kml', false);
console.log('in Parse file: ', docKMLentry.filename);
docKMLentry.getData( new zip.BlobWriter('text/xml'),
function(kmlText)
{
var fileReader = new FileReader();
fileReader.addEventListener("loadend", function()
{ docKML = fileReader.result;
if (typeof docKML == 'string') {
docKML = ( new window.DOMParser() ).parseFromString(docKML, "text/xml");
}
var geojson = toGeoJSON[extension](docKML);
//send data to esri converter
feats = geojson.features;
if (!feats || (feats.length === 0)) {
alert("No features found");
return;
} convertTo_esri();
});
得到了解决方案 - 简单地将 blob 对象作为输入文件传递给 zip.js 中的 zip.blobReader 函数
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.