2

I have to use KMZ files in my Leaflet Map. I found good plugins and tutorials to use KML files in Leaflet Maps but couldn't find a way to use KMZ files.

One of the plugin for using KML is : Leaflet-Omnivore. For KML all I have to do is(My Leaflet Map is in my ExtJs Application) :

var myMap =  Ext.ComponentQuery.query("leaflet")[0];
myMap.getMap().addLayer(omnivore.kml('http://url/doc.kml'))

Can any one guide me about how to use KMZ instead of KML in Leaflet?

If it is not possible then is there a way to convert KMZ to KML using JavaScript?

Abdul Rehman Yawar Khan
  • 1,048
  • 2
  • 17
  • 39
  • 1
    You would probably be interested in http://stackoverflow.com/questions/24243254/how-to-convert-kmz-file-to-kml-using-javascript and http://stackoverflow.com/questions/3498743/read-kmz-with-javascript – ghybs Mar 08 '16 at 13:00
  • @ghybs thanks for your comment. So there is no way to directly use KMZ files? Only way is that I unzip it using zip.js and use the resulted .kml file ? – Abdul Rehman Yawar Khan Mar 08 '16 at 13:34

2 Answers2

4

A KMZ file is just a zipped KML file, possibly with associated embedded images, icons, etc.

So any program that supports KMZ files internally unzips them to access their KML files.

That may be a reason why many open source programs do not bother supporting KMZ once KML support is implemented: you just need to use an additional unzipping library of your choice, to convert the KMZ to KML.

The linked posts give some JavaScript-based solutions for unzipping.

ghybs
  • 38,610
  • 6
  • 60
  • 83
1

OpenLayers 3 and Leaflet does not support KMZ. I made the KMZ parser up to depth level 3 its under construction but you can use it. The KMZ parsing is working. Here is the link to my GitHub repo.

https://github.com/engrabid411/kmzol3

dakab
  • 4,878
  • 8
  • 40
  • 60
Abid Nawaz
  • 848
  • 6
  • 17
  • @Suever I think you may not have read his answer. His answer is fine. He only links to his repository where you can download a parser. It's not like he can provide the entire source code. – oligofren Apr 20 '16 at 09:28
  • Thanks @oligofren. The KMZ. – Abid Nawaz Apr 20 '16 at 12:33