如何在openlayers中将shapefile导出到KML? [英] How to export shapefiles to KML in openlayers?

查看:192
本文介绍了如何在openlayers中将shapefile导出到KML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用openlayers或javascript以KML格式导出shapefile 有可能这样做吗? 预先感谢您的答复

I want to export shapefiles in KML format using openlayers or javascript Is it possible to do so? Thanks in advance for reply

推荐答案

  • 第一部分是shapeFiles:您必须在帮助下将其导入 您的QuantumGIS或shapeFileImporter或其他仪器 旨在与shapefile和数据库连接器一起使用,或者 mapServer.如果您想要有关此主题的更多信息,则必须 提供更多详细信息.例如.您使用什么空间数据库? 您使用mapServer等等.借助以下工具导入shapeFile 可能会实现openLayers,但我尚未测试还没完成 它可能非常脆弱,而且不是很轻松,因为 shapefile是二进制文件...

    • 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. If you want more information to this topic, you have to provide more details. E.g. what spatial DB do you use, what kind of mapServer do you use and so on. 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...

      第二部分是KML导出:如果在OL中有vectorLayer,则您 可以获取功能集合并将其传递给OpenLayers.Format.KML 写入功能,并生成KML结构化字符串...我 没有测试过,但这应该可以工作:

      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:

      var myKMLparser =新的OpenLayers.Format.KML;

      var myKMLparser = new OpenLayers.Format.KML;

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

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

      您可以在此处找到文档解析器...

      这篇关于如何在openlayers中将shapefile导出到KML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆