4

I have a kml and shp I would like to convert to an xml to use with geoxml3. How would I go about doing such a thing? The xml I generate should look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"     xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Districts</name>
<Style>
    <ListStyle>
        <listItemType>checkHideChildren</listItemType>
        <bgColor>00ffffff</bgColor>
        <maxSnippetLines>2</maxSnippetLines>
    </ListStyle>
</Style>
<Style id="trb655">
    <BalloonStyle>
        <text><![CDATA[<font font size='3' color="#aa0000"><b>$[name]</b></font>
              <table border='1' padding='1'>$[description]</table>                  
              <br><a href='http://shape2earth.com'><b>Shape2Earth</b></a>]]></text>
    </BalloonStyle>
    <LineStyle>
        <color>ff84685b</color>
    </LineStyle>
    <PolyStyle>
        <color>ff13e69b</color>
    </PolyStyle>
</Style>
<Style id="trb71">
    <BalloonStyle>
        <text><![CDATA[<font font size='3' color="#aa0000"><b>$[name]</b></font>
              <table border='1' padding='1'>$[description]</table>                  
              <br><a href='http://shape2earth.com'><b>Shape2Earth</b></a>]]></text>
    </BalloonStyle>
    <LineStyle>
        <color>ff84685b</color>
    </LineStyle>
    <PolyStyle>
        <color>ffeaed3b</color>
    </PolyStyle>
</Style>
<Style id="trb470">

The "Polystyle" and "BalloonStyle"; what can generate this with a shapefile or kml as a ref?

1

The geoxml3 library works with KML (which is just a variant of XML, anyway), so there is no need to "convert [your KML] to an XML." If you have Shapefiles you wan t to convert to KML files, you can use ogr2ogr.

ogr2ogr -f "KML" example.kml example.shp

You can generate KML programmatically in Python using PyKML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.