Aaron Kreider
Aaron Kreider

Reputation: 1819

PHP: Converting a KML into a KMZ

I've got a custom php script that creates a KML file. Now how do I convert it into KMZ?

Should I just run gzcompress() on it?

Or should I create a ZipArchive?

Upvotes: 1

Views: 1317

Answers (1)

Aaron Kreider
Aaron Kreider

Reputation: 1819

Creating a ZipArchive worked. I add the already created kml file to it.

  $zip = new ZipArchive();
  $zip_name = "c:\\kml\\".$sFilename.".kmz";
  $filename = "c:\\kml\\".$sFilename.".kml";
  $zip->open($zip_name, ZIPARCHIVE::CREATE);
  $zip->addFile($filename);
  $zip->close();

Upvotes: 4

Related Questions