Using KMZ file in Leaflet Map

情到浓时终转凉″ 提交于 2020-03-22 10:32:29

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/35867793/using-kmz-file-in-leaflet-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!