Skip to content Skip to sidebar Skip to footer

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? Thanks in advance for reply

Solution 1:

  • 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...

  • 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 = new OpenLayers.Format.KML;

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

here you can find the documentation to this parser...


Post a Comment for "How To Export Shapefiles To KML In Openlayers?"