Skip to content
/ go-kml Public

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

License

Notifications You must be signed in to change notification settings

twpayne/go-kml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

69bef76 · Apr 3, 2025
Apr 3, 2025
Apr 3, 2025
May 15, 2023
Oct 2, 2024
Oct 2, 2024
Mar 28, 2020
Jul 12, 2019
Apr 3, 2025
Nov 17, 2015
May 6, 2024
Mar 23, 2023
Apr 2, 2025
Jan 29, 2025
Apr 2, 2025
Oct 2, 2024
Oct 2, 2024
Oct 2, 2024
May 3, 2023
Oct 2, 2024
Oct 2, 2024
Oct 2, 2024

Repository files navigation

go-kml

PkgGoDev

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

MIT