简体   繁体   English

在传单地图中使用 KMZ 文件

[英]Using KMZ file in Leaflet Map

I have to use KMZ files in my Leaflet Map.我必须在传单地图中使用 KMZ 文件。 I found good plugins and tutorials to use KML files in Leaflet Maps but couldn't find a way to use KMZ files.我找到了在 Leaflet Maps 中使用 KML 文件的好插件和教程,但找不到使用KMZ文件的方法。

One of the plugin for using KML is : Leaflet-Omnivore .使用 KML 的插件之一是: Leaflet-Omnivore For KML all I have to do is(My Leaflet Map is in my ExtJs Application) :对于 KML,我所要做的就是(我的传单地图在我的 ExtJs 应用程序中):

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?谁能指导我如何在 Leaflet 中使用 KMZ 而不是 KML?

If it is not possible then is there a way to convert KMZ to KML using JavaScript?如果不可能,那么有没有办法使用 JavaScript 将 KMZ 转换为 KML?

A KMZ file is just a zipped KML file , possibly with associated embedded images, icons, etc. KMZ文件只是一个压缩的KML文件 ,可能带有关联的嵌入式图像,图标等。

So any program that supports KMZ files internally unzips them to access their KML files. 因此,任何支持KMZ文件的程序都会在内部将其解压缩以访问其KML文件。

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. 这可能就是为什么一旦实现KML支持,许多开放源代码程序就不会打扰支持KMZ的原因:您只需要使用您选择的附加解压缩库,即可将KMZ转换为KML。

The linked posts give some JavaScript-based solutions for unzipping. 链接的文章提供了一些基于JavaScript的解压缩解决方案。

OpenLayers 3 and Leaflet does not support KMZ. OpenLayers 3和Leaflet不支持KMZ。 I made the KMZ parser up to depth level 3 its under construction but you can use it. 我将KMZ解析器的深度构建为3级,但可以使用它。 The KMZ parsing is working. KMZ分析正在工作。 Here is the link to my GitHub repo. 这是我的GitHub存储库的链接。

https://github.com/engrabid411/kmzol3 https://github.com/engrabid411/kmzol3

Used in a project, this can load both kmz and kml files在项目中使用,这个可以同时加载kmz和kml文件

https://github.com/Raruto/leaflet-kmz https://github.com/Raruto/leaflet-kmz

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM