Package kml provides convenience methods for creating and writing KML documents.
Go
98
254 commits
updated Dec 31, 2025
Package kml provides convenience methods for creating and writing KML documents.
gx: extensions.encoding/xml package.Style and StyleMap elements.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.
icon Convenience functions for using standard KML icons.sphere Convenience functions for spherical geometry.MIT
24 followers · starred Sep 2019
Go
100.0%
Package kml provides convenience methods for creating and writing KML documents.
Go
98
254 commits
updated Dec 31, 2025
Package kml provides convenience methods for creating and writing KML documents.
gx: extensions.encoding/xml package.Style and StyleMap elements.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.
icon Convenience functions for using standard KML icons.sphere Convenience functions for spherical geometry.MIT
24 followers · starred Sep 2019
Go
100.0%