问题
How I can read the content in a KMZ (not KML) with JavaScript?
回答1:
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.
回答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);
回答3:
geoxml3 now supports kmz files (in the kmz branch).
来源:https://stackoverflow.com/questions/3498743/read-kmz-with-javascript