2

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

JuanPablo
  • 22,464
  • 33
  • 113
  • 159
  • 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
  • 195,511
  • 20
  • 184
  • 225
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
  • 153,563
  • 13
  • 208
  • 237