Package kml provides convenince methods for creating and writing KML documents.
Clone or download
twpayne Merge pull request #8 from twpayne/hike-and-fly-route-xcplanner-example
Add XC Planner output to hike and fly example
Latest commit a5dbcab Jan 28, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/hike-and-fly-route-kml Add XC Planner output to hike and fly example Jan 28, 2018
icon Add ShapeHref Jan 14, 2018
sphere Add sphere library Apr 19, 2017
.travis.yml Drop golint from Travis CI Dec 11, 2016
LICENSE Add LICENSE Nov 17, 2015
README.md Add links to icon and sphere Jul 31, 2017
example_test.go Use keyed fields Jul 24, 2017
kml.go Remove unused function Aug 2, 2017
kml_test.go Factor out SharedElement.URL Apr 16, 2017

README.md

go-kml

Build Status GoDoc Report Card

Package kml provides convenience methods for creating and writing KML documents.

Key Features

  • Simple API for building arbitrarily complex KML documents.
  • Support for all KML elements, including Google Earth gx: extensions.
  • Compatibilty with the standard library encoding/xml package.
  • Pretty (neatly indented) and compact (minimum size) output formats.
  • Support for shared Style and StyleMap elements.
  • Simple mapping between functions and KML elements.
  • Convenience functions for using standard KML icons.
  • Convenience functions for spherical geometry.

Example

func ExampleKML() {
    k := kml.KML(
        kml.Placemark(
            kml.Name("Simple placemark"),
            kml.Description("Attached to the ground. Intelligently places itself at the height of the underlying terrain."),
            kml.Point(
                kml.Coordinates(kml.Coordinate{Lon: -122.0822035425683, Lat: 37.42228990140251}),
            ),
        ),
    )
    if err := k.WriteIndent(os.Stdout, "", "  "); err != nil {
        log.Fatal(err)
    }
}

Output:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Placemark>
    <name>Simple placemark</name>
    <description>Attached to the ground. Intelligently places itself at the height of the underlying terrain.</description>
    <Point>
      <coordinates>-122.0822035425683,37.42228990140251</coordinates>
    </Point>
  </Placemark>
</kml>

There are more examples in the documentation corresponding to the examples in the KML tutorial.

Subpackages

  • icon Convenience functions for using standard KML icons.
  • sphere Convenience functions for spherical geometry.

License