3

How I can read the content in a KMZ (not KML) with JavaScript?

JuanPablo
  • 23,792
  • 39
  • 118
  • 164
  • um.... so which is it? KML per your title, or KMZ per your question content? – Jason S Aug 17 '10 at 01:55
  • Do you actually want to do something with the KML inside the KMZ (which is simply a ZIP file) with your JavaScript, or do you simply want to display the data in the KML inside the KMZ on a map? – Tony Miller Aug 19 '10 at 01:02

3 Answers3

3

Well you need to see if it is possible to unzip the files. I would look at this stackoverflow post on using JavaScript. After that you will probably have a string of XML which you will need to convert to XML using the DOM parser.

Community
  • 1
  • 1
epascarello
  • 204,599
  • 20
  • 195
  • 236
2

You have to use geoxml3.js with ZipFile.complete.js available at KMZ

     <script src="js/ZipFile.complete.js"></script>
     <script src="js/geoxmlv3.js"></script>

     var map = new google.maps.Map(document.getElementById(mapId), {
        zoom: 11,center: {lat: 0,lng: 0}
      });
      var myParser = new geoXML3.parser({
        map: map
      });
      myParser.parse(fileName);
0

geoxml3 now supports kmz files (in the kmz branch).

geocodezip
  • 158,664
  • 13
  • 220
  • 245