# README
go-kml
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
andStyleMap
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
# Functions
Address returns a new AddressElement.
Alias returns a new AliasElement.
Altitude returns a new AltitudeElement.
AltitudeMode returns a new AltitudeModeElement.
BalloonStyle returns a new BalloonStyleElement.
Begin returns a new BeginElement.
BgColor returns a new BgColorElement.
BottomFOV returns a new BottomFOVElement.
Camera returns a new CameraElement.
Change returns a new ChangeElement.
Color returns a new ColorElement.
ColorMode returns a new ColorModeElement.
Cookie returns a new CookieElement.
Coordinates returns a new CoordinatesElement.
CoordinatesFlat returns a new Coordinates element from flat coordinates.
CoordinatesSlice returns a new CoordinatesArrayElement.
Create returns a new CreateElement.
Data returns a new DataElement.
Delete returns a new DeleteElement.
Description returns a new DescriptionElement.
DisplayMode returns a new DisplayModeElement.
DisplayName returns a new DisplayNameElement.
Document returns a new DocumentElement.
DrawOrder returns a new DrawOrderElement.
East returns a new EastElement.
End returns a new EndElement.
Expires returns a new ExpiresElement.
ExtendedData returns a new ExtendedDataElement.
Extrude returns a new ExtrudeElement.
Fill returns a new FillElement.
FlyToView returns a new FlyToViewElement.
Folder returns a new FolderElement.
GridOrigin returns a new GridOriginElement.
GroundOverlay returns a new GroundOverlayElement.
GxAbstractTourPrimitive returns a new GxAbstractTourPrimitiveElement.
GxAltitudeMode returns a new GxAltitudeModeElement.
GxAltitudeOffset returns a new GxAltitudeOffsetElement.
GxAngles returns a new GxAnglesElement.
GxAnimatedUpdate returns a new GxAnimatedUpdateElement.
GxBalloonVisibility returns a new GxBalloonVisibilityElement.
GxCoord returns a new GxCoordElement.
GxDelayedStart returns a new GxDelayedStartElement.
GxDrawOrder returns a new GxDrawOrderElement.
GxDuration returns a new GxDurationElement.
GxFlyTo returns a new GxFlyToElement.
GxFlyToMode returns a new GxFlyToModeElement.
GxH returns a new GxHElement.
GxHorizFOV returns a new GxHorizFOVElement.
GxInterpolate returns a new GxInterpolateElement.
GxKML returns a new GxKMLElement.
GxLabelVisibility returns a new GxLabelVisibilityElement.
GxLatLonQuad returns a new GxLatLonQuadElement.
GxMultiTrack returns a new GxMultiTrackElement.
GxOption returns a new gx:option element.
GxOuterColor returns a new GxOuterColorElement.
GxOuterWidth returns a new GxOuterWidthElement.
GxPhysicalWidth returns a new GxPhysicalWidthElement.
GxPlaylist returns a new GxPlaylistElement.
GxPlayMode returns a new GxPlayModeElement.
GxRank returns a new GxRankElement.
GxSimpleArrayData returns a new GxSimpleArrayDataElement.
GxSimpleArrayField returns a new GxSimpleArrayFieldElement.
GxSoundCue returns a new GxSoundCueElement.
GxTimeSpan returns a new GxTimeSpanElement.
GxTimeStamp returns a new GxTimeStampElement.
GxTour returns a new GxTourElement.
GxTourControl returns a new GxTourControlElement.
GxTrack returns a new GxTrackElement.
GxViewerOptions returns a new GxViewerOptionsElement.
GxW returns a new GxWElement.
GxWait returns a new GxWaitElement.
GxX returns a new GxXElement.
GxY returns a new GxYElement.
Heading returns a new HeadingElement.
HotSpot returns a new HotSpotElement.
Href returns a new HrefElement.
HttpQuery returns a new HttpQueryElement.
Icon returns a new IconElement.
IconStyle returns a new IconStyleElement.
ImagePyramid returns a new ImagePyramidElement.
InnerBoundaryIs returns a new InnerBoundaryIsElement.
ItemIcon returns a new ItemIconElement.
Key returns a new KeyElement.
KML returns a new KMLElement.
LabelStyle returns a new LabelStyleElement.
Latitude returns a new LatitudeElement.
LatLonAltBox returns a new LatLonAltBoxElement.
LatLonBox returns a new LatLonBoxElement.
LeftFOV returns a new LeftFOVElement.
LinearRing returns a new LinearRingElement.
LineString returns a new LineStringElement.
LineStyle returns a new LineStyleElement.
Link returns a new LinkElement.
LinkDescription returns a new LinkDescriptionElement.
LinkName returns a new LinkNameElement.
LinkSnippet returns a new LinkSnippetElement.
ListItemType returns a new ListItemTypeElement.
ListStyle returns a new ListStyleElement.
Location returns a new LocationElement.
LOD returns a new LODElement.
Longitude returns a new LongitudeElement.
LookAt returns a new LookAtElement.
MaxAltitude returns a new MaxAltitudeElement.
MaxFadeExtent returns a new MaxFadeExtentElement.
MaxHeight returns a new MaxHeightElement.
MaxLODPixels returns a new MaxLODPixelsElement.
MaxSessionLength returns a new MaxSessionLengthElement.
MaxWidth returns a new MaxWidthElement.
Message returns a new MessageElement.
Metadata returns a new MetadataElement.
MinAltitude returns a new MinAltitudeElement.
MinFadeExtent returns a new MinFadeExtentElement.
MinLODPixels returns a new MinLODPixelsElement.
MinRefreshPeriod returns a new MinRefreshPeriodElement.
Model returns a new ModelElement.
ModelScale returns a new ModelScaleElement.
MultiGeometry returns a new MultiGeometryElement.
Name returns a new NameElement.
NamedSchema returns a new SchemaElement with the given name.
Near returns a new NearElement.
NetworkLink returns a new NetworkLinkElement.
NetworkLinkControl returns a new NetworkLinkControlElement.
North returns a new NorthElement.
Open returns a new OpenElement.
Orientation returns a new OrientationElement.
OuterBoundaryIs returns a new OuterBoundaryIsElement.
Outline returns a new OutlineElement.
OverlayXY returns a new OverlayXYElement.
Pair returns a new PairElement.
PhoneNumber returns a new PhoneNumberElement.
PhotoOverlay returns a new PhotoOverlayElement.
Placemark returns a new PlacemarkElement.
Point returns a new PointElement.
Polygon returns a new PolygonElement.
PolyStyle returns a new PolyStyleElement.
Range returns a new RangeElement.
RefreshInterval returns a new RefreshIntervalElement.
RefreshMode returns a new RefreshModeElement.
RefreshVisibility returns a new RefreshVisibilityElement.
Region returns a new RegionElement.
ResourceMap returns a new ResourceMapElement.
RightFOV returns a new RightFOVElement.
Roll returns a new RollElement.
Rotation returns a new RotationElement.
RotationXY returns a new RotationXYElement.
Scale returns a new ScaleElement.
Schema returns a new SchemaElement.
SchemaData returns a new SchemaDataElement.
ScreenOverlay returns a new ScreenOverlayElement.
ScreenXY returns a new ScreenXYElement.
Shape returns a new ShapeElement.
SharedStyle returns a new StyleElement with the given id.
SharedStyleMap returns a new StyleMapElement with the given id.
SimpleData returns a new SimpleDataElement.
SimpleField returns a new SimpleFieldElement.
Size returns a new SizeElement.
Snippet returns a new SnippetElement.
SourceHref returns a new SourceHrefElement.
South returns a new SouthElement.
State returns a new StateElement.
Style returns a new StyleElement.
StyleMap returns a new StyleMapElement.
StyleURL returns a new StyleURLElement.
TargetHref returns a new TargetHrefElement.
Tessellate returns a new TessellateElement.
Text returns a new TextElement.
TextColor returns a new TextColorElement.
TileSize returns a new TileSizeElement.
Tilt returns a new TiltElement.
TimeSpan returns a new TimeSpanElement.
TimeStamp returns a new TimeStampElement.
TopFOV returns a new TopFOVElement.
Update returns a new UpdateElement.
URL returns a new URLElement.
Value returns a new ValueElement.
ViewBoundScale returns a new ViewBoundScaleElement.
ViewFormat returns a new ViewFormatElement.
ViewRefreshMode returns a new ViewRefreshModeElement.
ViewRefreshTime returns a new ViewRefreshTimeElement.
ViewVolume returns a new ViewVolumeElement.
Visibility returns a new VisibilityElement.
West returns a new WestElement.
When returns a new WhenElement.
Width returns a new WidthElement.
WriteKMZ writes a KMZ file containing files to w.
X returns a new XElement.
Y returns a new YElement.
Z returns a new ZElement.
# Constants
AltitudeModeEnums.
AltitudeModeEnums.
AltitudeModeEnums.
ColorModeEnums.
ColorModeEnums.
DisplayModeEnums.
DisplayModeEnums.
GridOriginEnums.
GridOriginEnums.
GxAltitudeModeEnums.
GxAltitudeModeEnums.
GxAltitudeModeEnums.
GxAltitudeModeEnums.
GxAltitudeModeEnums.
GxFlyToModeEnums.
GxFlyToModeEnums.
GxNamespace is the default namespace for Google Earth extensions.
GxOptionNames.
GxOptionNames.
GxOptionNames.
GxPlayModeEnums.
ItemIconStateEnums.
ItemIconStateEnums.
ItemIconStateEnums.
ItemIconStateEnums.
ItemIconStateEnums.
ItemIconStateEnums.
ListItemTypeEnums.
ListItemTypeEnums.
ListItemTypeEnums.
ListItemTypeEnums.
Namespace is the default namespace.
RefreshModeEnums.
RefreshModeEnums.
RefreshModeEnums.
ShapeEnums.
ShapeEnums.
ShapeEnums.
StyleStateEnums.
StyleStateEnums.
UnitsEnums.
UnitsEnums.
UnitsEnums.
ViewRefreshModeEnums.
ViewRefreshModeEnums.
ViewRefreshModeEnums.
ViewRefreshModeEnums.
# Structs
An AddressElement is an address element.
An AliasElement is an Alias element.
An AltitudeElement is an altitude element.
An AltitudeModeElement is an altitudeMode element.
A BalloonStyleElement is a BalloonStyle element.
A BeginElement is a begin element.
A BgColorElement is a bgColor element.
A BottomFOVElement is a bottomFov element.
A CameraElement is a Camera element.
A ChangeElement is a Change element.
A ColorElement is a color element.
A ColorModeElement is a colorMode element.
A CookieElement is a cookie element.
A Coordinate is a single geographical coordinate.
CoordinatesFlatElement is a coordinates element composed of flat coordinates.
A CreateElement is a Create element.
A DataElement is a Data element.
A DeleteElement is a Delete element.
A DescriptionElement is a description element.
A DisplayModeElement is a displayMode element.
A DisplayNameElement is a displayName element.
A DocumentElement is a Document element.
A DrawOrderElement is a drawOrder element.
An EastElement is an east element.
An EndElement is an end element.
An ExpiresElement is an expires element.
An ExtendedDataElement is an ExtendedData element.
An ExtrudeElement is an extrude element.
A FillElement is a fill element.
A FlyToViewElement is a flyToView element.
A FolderElement is a Folder element.
A GridOriginElement is a gridOrigin element.
A GroundOverlayElement is a GroundOverlay element.
A GxAbstractTourPrimitiveElement is an AbstractTourPrimitive element.
A GxAltitudeModeElement is an altitudeMode element.
A GxAltitudeOffsetElement is an altitudeOffset element.
A GxAnglesElement is a gx:angles element.
A GxAnimatedUpdateElement is an AnimatedUpdate element.
A GxBalloonVisibilityElement is a balloonVisibility element.
A GxDelayedStartElement is a delayedStart element.
A GxDrawOrderElement is a drawOrder element.
A GxDurationElement is a duration element.
A GxFlyToElement is a FlyTo element.
A GxFlyToModeElement is a flyToMode element.
A GxHElement is a h element.
A GxHorizFOVElement is a horizFov element.
A GxInterpolateElement is an interpolate element.
A GxKMLElement is a kml element with gx: extensions.
A GxLabelVisibilityElement is a labelVisibility element.
A GxLatLonQuadElement is a LatLonQuad element.
A GxMultiTrackElement is a MultiTrack element.
A GxOptionElement is a gx:option element.
A GxOuterColorElement is an outerColor element.
A GxOuterWidthElement is an outerWidth element.
A GxPhysicalWidthElement is a physicalWidth element.
A GxPlaylistElement is a Playlist element.
A GxPlayModeElement is a playMode element.
A GxRankElement is a rank element.
A GxSimpleArrayDataElement is a SimpleArrayData element.
A GxSimpleArrayFieldElement is a gx:SimpleArrayField element.
A GxSoundCueElement is a SoundCue element.
A GxTimeSpanElement is a TimeSpan element.
A GxTimeStampElement is a TimeStamp element.
A GxTourControlElement is a TourControl element.
A GxTourElement is a Tour element.
A GxTrackElement is a Track element.
A GxViewerOptionsElement is a ViewerOptions element.
A GxWaitElement is a Wait element.
A GxWElement is a w element.
A GxXElement is a x element.
A GxYElement is a y element.
A HeadingElement is a heading element.
A HotSpotElement is a hotSpot element.
A HrefElement is a href element.
A HttpQueryElement is a httpQuery element.
An IconElement is an Icon element.
An IconStyleElement is an IconStyle element.
An ImagePyramidElement is an ImagePyramid element.
An InnerBoundaryIsElement is an innerBoundaryIs element.
An ItemIconElement is an ItemIcon element.
A KeyElement is a key element.
A KMLElement is a kml element.
A LabelStyleElement is a LabelStyle element.
A LatitudeElement is a latitude element.
A LatLonAltBoxElement is a LatLonAltBox element.
A LatLonBoxElement is a LatLonBox element.
A LeftFOVElement is a leftFov element.
A LinearRingElement is a LinearRing element.
A LineStringElement is a LineString element.
A LineStyleElement is a LineStyle element.
A LinkDescriptionElement is a linkDescription element.
A LinkElement is a Link element.
A LinkNameElement is a linkName element.
A LinkSnippetElement is a LinkSnippet element.
A ListItemTypeElement is a listItemType element.
A ListStyleElement is a ListStyle element.
A LocationElement is a Location element.
A LODElement is a Lod element.
A LongitudeElement is a longitude element.
A LookAtElement is a LookAt element.
A MaxAltitudeElement is a maxAltitude element.
A MaxFadeExtentElement is a maxFadeExtent element.
A MaxHeightElement is a maxHeight element.
A MaxLODPixelsElement is a maxLodPixels element.
A MaxSessionLengthElement is a maxSessionLength element.
A MaxWidthElement is a maxWidth element.
A MessageElement is a message element.
A MetadataElement is a Metadata element.
A MinAltitudeElement is a minAltitude element.
A MinFadeExtentElement is a minFadeExtent element.
A MinLODPixelsElement is a minLodPixels element.
A MinRefreshPeriodElement is a minRefreshPeriod element.
A ModelElement is a Model element.
A ModelScaleElement is a Scale element.
A MultiGeometryElement is a MultiGeometry element.
A NameElement is a name element.
A NearElement is a near element.
A NetworkLinkControlElement is a NetworkLinkControl element.
A NetworkLinkElement is a NetworkLink element.
A NorthElement is a north element.
An OpenElement is an open element.
An OrientationElement is an Orientation element.
An OuterBoundaryIsElement is an outerBoundaryIs element.
An OutlineElement is an outline element.
An OverlayXYElement is an overlayXY element.
A PairElement is a Pair element.
A PhoneNumberElement is a phoneNumber element.
A PhotoOverlayElement is a PhotoOverlay element.
A PlacemarkElement is a Placemark element.
A PointElement is a Point element.
A PolygonElement is a Polygon element.
A PolyStyleElement is a PolyStyle element.
A RangeElement is a range element.
A RefreshIntervalElement is a refreshInterval element.
A RefreshModeElement is a refreshMode element.
A RefreshVisibilityElement is a refreshVisibility element.
A RegionElement is a Region element.
A ResourceMapElement is a ResourceMap element.
A RightFOVElement is a rightFov element.
A RollElement is a roll element.
A RotationElement is a rotation element.
A RotationXYElement is a rotationXY element.
A ScaleElement is a scale element.
A SchemaDataElement is a SchemaData element.
A SchemaElement is a Schema element.
A ScreenOverlayElement is a ScreenOverlay element.
A ScreenXYElement is a screenXY element.
A ShapeElement is a shape element.
A SimpleDataElement is a SimpleData element.
A SimpleFieldElement is a SimpleField element.
A SizeElement is a size element.
A SnippetElement is a snippet element.
A SourceHrefElement is a sourceHref element.
A SouthElement is a south element.
A StateElement is a state element.
A StyleElement is a Style element.
A StyleMapElement is a StyleMap element.
A StyleURLElement is a styleUrl element.
A TargetHrefElement is a targetHref element.
A TessellateElement is a tessellate element.
A TextColorElement is a textColor element.
A TextElement is a text element.
A TileSizeElement is a tileSize element.
A TiltElement is a tilt element.
A TimeSpanElement is a TimeSpan element.
A TimeStampElement is a TimeStamp element.
A TopFOVElement is a topFov element.
A UpdateElement is a Update element.
A URLElement is a Url element.
A ValueElement is a value element.
A Vec2 is a vec2.
A ViewBoundScaleElement is a viewBoundScale element.
A ViewFormatElement is a viewFormat element.
A ViewRefreshModeElement is a viewRefreshMode element.
A ViewRefreshTimeElement is a viewRefreshTime element.
A ViewVolumeElement is a ViewVolume element.
A VisibilityElement is a visibility element.
A WestElement is a west element.
A WhenElement is a when element.
A WidthElement is a width element.
A XElement is a x element.
A YElement is a y element.
A ZElement is a z element.
# Interfaces
An Element is a KML element.
A ParentElement is a KML element with children.
A TopLevelElement is a top level KML element.
# Type aliases
An AltitudeModeEnum is an altitudeModeEnumType.
A ColorModeEnum is a colorModeEnumType.
CoordinatesElement is a coordinates element composed of Coordinates.
CoordinatesSliceElement is a coordinates element composed of a slice of []float64s.
A DisplayModeEnum is a displayModeEnumType.
A GridOriginEnum is a gridOriginEnumType.
A GxAltitudeModeEnum is an altitudeModeEnumType.
A GxCoordElement is a gx:coord element.
A GxFlyToModeEnum is a flyToModeEnumType.
A GxOptionName is a gx:option name.
A GxPlayModeEnum is a playModeEnumType.
An ItemIconStateEnum is an itemIconStateEnumType.
A ListItemTypeEnum is a listItemTypeEnumType.
A RefreshModeEnum is a refreshModeEnumType.
A ShapeEnum is a shapeEnumType.
A StyleStateEnum is a styleStateEnumType.
A UnitsEnum is a unitsEnumType.
A ViewRefreshModeEnum is a viewRefreshModeEnumType.