6

Anyone knows a simple JavaScript library implementing the UNZIP algorithm? No disk-file access, only zip and unzip a string of values.

There are ActiveX, using WinZIP and other client dependent software for ZIP, written in JS. But no pure JavaScript algorithm implementation.

I would use it for displaying KMZ files in a HTML page with the GMap object (google maps). The KMZ file is just a zipped KML file. I want to unzip a KMZ file and feed the KML to GMap.

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
Trident Splash
  • 649
  • 2
  • 10
  • 25

5 Answers5

2

No need to unzip the KMZ file as Google Maps absolutely understands it. You can check it, simply search for the URL where your KMZ file is located in the Google Maps web interface and it will show its content on the map.

Here is a demo.

viam0Zah
  • 25,949
  • 8
  • 77
  • 100
1

kthoom implements unzip on a binary string: http://kthoom.googlecode.com/

codedread
  • 1,312
  • 11
  • 18
1

I know this is an old question with an accepted answer, but just for the sake of interesting information, I'll post another answer. I put together a javascript-only library to read and extract zip files from any browser. It does not require Mozilla's ZipReader nor any ActiveX (aside from XMLHttpRequest).

You can see a working example here:
http://cheeso.members.winisp.net/Unzip-Example.htm

And you can download the source code from here:
http://cheeso.members.winisp.net/examples.aspx#js

Cheeso
  • 189,189
  • 101
  • 473
  • 713
1

Perhaps ZipReader from Mozilla can be used for what you are after.

https://developer.mozilla.org/en/nsIZipReader

Crescent Fresh
  • 115,249
  • 25
  • 154
  • 140
mr-euro
  • 2,732
  • 5
  • 23
  • 27
  • 1
    Reading your question again actually made me wonder why you need to unzip KMZ to KML to be used with Google Maps when both file formats can be used directly. http://maps.google.com/support/bin/answer.py?hl=en&answer=41136 – mr-euro May 23 '09 at 21:46
  • yes, you're right... some guys have some issues, tough http://groups.google.com/group/Google-Maps-API/browse_thread/thread/c0efb3a854563312 – Trident Splash May 23 '09 at 22:42
  • but, the nslZipReader would only run on Mozilla's browser right? – Trident Splash May 23 '09 at 22:46
  • Yes ZipReader is only for Mozilla (Gecko browsers). But you could use ActiveX for IE and Zip Reader for the rest. Anyhow, regarding the eventual issues with KMZ try this alternative JS snippet. It should allow all elements of the KMZ file to be properly displayed: http://www.dcs.shef.ac.uk/~mark/blog/2008/11/easy-map-embedding_22.html – mr-euro May 23 '09 at 23:09
1

DotNetZip has a COM interface, that can be accessed from Javascript. It has a stream-to-stream unzip capability, but I have never tried using that from Javascript.
Also I have never tried using the library in any way from within IE.

Cheeso
  • 189,189
  • 101
  • 473
  • 713