简体   繁体   English

如何在openlayers中将shapefile导出到KML?

[英]How to export shapefiles to KML in openlayers?

I want to export shapefiles in KML format using openlayers or javascript Is it possible to do so? 我想使用openlayers或javascript以KML格式导出shapefile。可以这样做吗? Thanks in advance for reply 预先感谢您的答复

  • First part is the shapeFiles: You have to import them with the help of your QuantumGIS or shapeFileImporter or some other instrument meant to work with shapefiles and your database connector or mapServer. 第一部分是shapeFiles:您必须在QuantumGIS或shapeFileImporter或其他旨在与shapefile和数据库连接器或mapServer一起使用的工具的帮助下导入它们。 If you want more information to this topic, you have to provide more details. 如果您需要有关此主题的更多信息,则必须提供更多详细信息。 Eg what spatial DB do you use, what kind of mapServer do you use and so on. 例如,您使用什么空间数据库,您使用哪种mapServer等等。 Importing shapeFiles with the help of openLayers may be possible with this but i haven't tested it yet and it could be very vulnerable and not very easy going, because the shapefiles are binary... 用的OpenLayers的帮助下导入shape文件可能与 ,但我还没有测试但它可能是很脆弱的,不很随和,因为shapefile是二进制...

  • Second part is the KML export: If you have a vectorLayer in OL, you can get a feature collection and pass it to the OpenLayers.Format.KML to a write function and it produces the KML structured string... I havne't tested it, but this should work: 第二部分是KML导出:如果您在OL中有vectorLayer,则可以获取功能集合并将其传递给OpenLayers.Format.KML到写入函数,并产生KML结构化字符串...我没有测试过它,但这应该工作:

    var myKMLparser = new OpenLayers.Format.KML; var myKMLparser = new OpenLayers.Format.KML;

    var myKMLStructuredString = myKMLparser.write(myVectorLayer.features); var myKMLStructuredString = myKMLparser.write(myVectorLayer.features);

here you can find the documentation to this parser... 在这里您可以找到此解析器的文档 ...

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

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