For KMZ - If you're using ASP.NET or anything .NET for that matter, you should be able to use the VisualJ# libraries to compress the kml output....that's what I do for everything that I output into KMZ from C#. First add a reference in your project to the vjslib dll. Here's a simple example of adding a single kml file into a KMZ.....there's a little more work if you have to add more files/images:
Code:
// Create the ZipOutputStream that will write the kmz
ZipOutputStream zo = new ZipOutputStream(new java.io.FileOutputStream(safeFileName + ".kmz"));
// Open a FileInputStream to read the already written kml
java.io.FileInputStream fis = new java.io.FileInputStream(safeFileName + ".kml");
// Create a ZipEntry object for every file you plan to add to the zip.
ZipEntry ze = new ZipEntry(safeFileName + ".kml");
ze.setMethod(ZipEntry.DEFLATED);
zo.putNextEntry(ze);
// Add the bytes for that ZipEntry
sbyte[] buffer = new sbyte[1024];
int len = 0;
while ((len = fis.read(buffer)) >= 0)
{
zo.write(buffer, 0, len);
}
// Clean up
zo.closeEntry();
fis.close();
zo.close();
--------------------
There are 10 kinds of people in this world...
those that understand binary, and those that don't.