Documentation ¶
Overview ¶
Package kml provides convenience methods for creating and writing KML documents.
See https://developers.google.com/kml/
Goals
- Convenient API for creating both simple and complex KML documents.
- 1:1 mapping between functions and KML elements.
Non-goals
- Protection against generating invalid documents.
- Concealment of KML complexity.
- Fine-grained control over generated XML.
Index ¶
- Constants
- type CompoundElement
- func BalloonStyle(children ...Element) *CompoundElement
- func Camera(children ...Element) *CompoundElement
- func Change(children ...Element) *CompoundElement
- func Create(children ...Element) *CompoundElement
- func Data(children ...Element) *CompoundElement
- func Delete(children ...Element) *CompoundElement
- func Document(children ...Element) *CompoundElement
- func ExtendedData(children ...Element) *CompoundElement
- func Folder(children ...Element) *CompoundElement
- func GroundOverlay(children ...Element) *CompoundElement
- func GxAnimatedUpdate(children ...Element) *CompoundElement
- func GxFlyTo(children ...Element) *CompoundElement
- func GxKML(children ...Element) *CompoundElement
- func GxLatLonQuad(children ...Element) *CompoundElement
- func GxMultiTrack(children ...Element) *CompoundElement
- func GxNetworkLink(children ...Element) *CompoundElement
- func GxPlaylist(children ...Element) *CompoundElement
- func GxSimpleArrayField(name, _type string) *CompoundElement
- func GxSoundCue(children ...Element) *CompoundElement
- func GxTour(children ...Element) *CompoundElement
- func GxTourControl(children ...Element) *CompoundElement
- func GxTourPrimitive(children ...Element) *CompoundElement
- func GxTrack(children ...Element) *CompoundElement
- func GxWait(children ...Element) *CompoundElement
- func Icon(children ...Element) *CompoundElement
- func IconStyle(children ...Element) *CompoundElement
- func InnerBoundaryIs(value Element) *CompoundElement
- func KML(children ...Element) *CompoundElement
- func LabelStyle(children ...Element) *CompoundElement
- func LatLonBox(children ...Element) *CompoundElement
- func LineString(children ...Element) *CompoundElement
- func LineStyle(children ...Element) *CompoundElement
- func LinearRing(children ...Element) *CompoundElement
- func Link(children ...Element) *CompoundElement
- func ListStyle(children ...Element) *CompoundElement
- func LookAt(children ...Element) *CompoundElement
- func Model(children ...Element) *CompoundElement
- func MultiGeometry(children ...Element) *CompoundElement
- func NetworkLink(children ...Element) *CompoundElement
- func NetworkLinkControl(children ...Element) *CompoundElement
- func OuterBoundaryIs(value Element) *CompoundElement
- func Pair(children ...Element) *CompoundElement
- func Placemark(children ...Element) *CompoundElement
- func Point(children ...Element) *CompoundElement
- func PolyStyle(children ...Element) *CompoundElement
- func Polygon(children ...Element) *CompoundElement
- func Region(children ...Element) *CompoundElement
- func SchemaData(schemaURL string, children ...Element) *CompoundElement
- func ScreenOverlay(children ...Element) *CompoundElement
- func SimpleField(name, _type string, children ...Element) *CompoundElement
- func Style(children ...Element) *CompoundElement
- func StyleMap(children ...Element) *CompoundElement
- func TimeSpan(children ...Element) *CompoundElement
- func TimeStamp(children ...Element) *CompoundElement
- type Coordinate
- type CoordinatesArrayElement
- type CoordinatesElement
- type CoordinatesFlatElement
- type Element
- type GxAngle
- type SharedElement
- type SimpleElement
- func Address(value string) *SimpleElement
- func Altitude(value float64) *SimpleElement
- func AltitudeMode(value string) *SimpleElement
- func Begin(value time.Time) *SimpleElement
- func BgColor(value color.Color) *SimpleElement
- func Color(value color.Color) *SimpleElement
- func ColorMode(value string) *SimpleElement
- func Cookie(value string) *SimpleElement
- func Description(value string) *SimpleElement
- func DisplayName(value string) *SimpleElement
- func DrawOrder(value int) *SimpleElement
- func East(value float64) *SimpleElement
- func End(value time.Time) *SimpleElement
- func Expires(value time.Time) *SimpleElement
- func Extrude(value bool) *SimpleElement
- func Fill(value bool) *SimpleElement
- func FlyToView(value bool) *SimpleElement
- func GxAltitudeMode(value string) *SimpleElement
- func GxAltitudeOffset(value float64) *SimpleElement
- func GxAngles(value GxAngle) *SimpleElement
- func GxBalloonVisibility(value bool) *SimpleElement
- func GxCoord(value Coordinate) *SimpleElement
- func GxDelayedStart(value float64) *SimpleElement
- func GxDuration(value float64) *SimpleElement
- func GxLabelVisibility(value bool) *SimpleElement
- func GxOuterColor(value color.Color) *SimpleElement
- func GxOuterWidth(value float64) *SimpleElement
- func GxPhysicalWidth(value float64) *SimpleElement
- func HTTPQuery(value string) *SimpleElement
- func Heading(value float64) *SimpleElement
- func HotSpot(value Vec2) *SimpleElement
- func Href(value string) *SimpleElement
- func Key(value string) *SimpleElement
- func Latitude(value float64) *SimpleElement
- func LinkDescription(value string) *SimpleElement
- func LinkName(value string) *SimpleElement
- func LinkSnippet(maxLines int, value string) *SimpleElement
- func ListItemType(value string) *SimpleElement
- func Longitude(value float64) *SimpleElement
- func MaxAltitude(value float64) *SimpleElement
- func MaxFadeExtent(value int) *SimpleElement
- func MaxLodPixel(value int) *SimpleElement
- func Message(value string) *SimpleElement
- func MinAltitude(value float64) *SimpleElement
- func MinFadeExtent(value int) *SimpleElement
- func MinLodPixel(value int) *SimpleElement
- func Name(value string) *SimpleElement
- func North(value float64) *SimpleElement
- func Open(value bool) *SimpleElement
- func Outline(value bool) *SimpleElement
- func OverlayXY(value Vec2) *SimpleElement
- func PhoneNumber(value string) *SimpleElement
- func Range(value float64) *SimpleElement
- func RefreshInterval(value float64) *SimpleElement
- func RefreshMode(value string) *SimpleElement
- func RefreshVisibility(value bool) *SimpleElement
- func Roll(value float64) *SimpleElement
- func Rotation(value float64) *SimpleElement
- func RotationXY(value Vec2) *SimpleElement
- func Scale(value float64) *SimpleElement
- func ScreenXY(value Vec2) *SimpleElement
- func SimpleData(name, value string) *SimpleElement
- func Size(value Vec2) *SimpleElement
- func Snippet(value string) *SimpleElement
- func South(value float64) *SimpleElement
- func StyleURL(value string) *SimpleElement
- func TargetHref(value string) *SimpleElement
- func Tessellate(value bool) *SimpleElement
- func Text(value string) *SimpleElement
- func Tilt(value float64) *SimpleElement
- func Value(value string) *SimpleElement
- func ViewBoundScale(value float64) *SimpleElement
- func ViewFormat(value string) *SimpleElement
- func ViewRefreshMode(value string) *SimpleElement
- func ViewRefreshTime(value float64) *SimpleElement
- func Visibility(value bool) *SimpleElement
- func West(value float64) *SimpleElement
- func When(value time.Time) *SimpleElement
- func Width(value float64) *SimpleElement
- type Vec2
Examples ¶
Constants ¶
const ( // Namespace is the default namespace. Namespace = "http://www.opengis.net/kml/2.2" // GxNamespace is the default namespace for Google Earth extensions. GxNamespace = "http://www.google.com/kml/ext/2.2" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompoundElement ¶
type CompoundElement struct { xml.StartElement // contains filtered or unexported fields }
A CompoundElement is an Element with children.
func BalloonStyle ¶
func BalloonStyle(children ...Element) *CompoundElement
BalloonStyle returns a new BalloonStyle element.
func Camera ¶
func Camera(children ...Element) *CompoundElement
Camera returns a new Camera element.
func Change ¶
func Change(children ...Element) *CompoundElement
Change returns a new Change element.
func Create ¶
func Create(children ...Element) *CompoundElement
Create returns a new Create element.
func Delete ¶
func Delete(children ...Element) *CompoundElement
Delete returns a new Delete element.
func Document ¶
func Document(children ...Element) *CompoundElement
Document returns a new Document element.
func ExtendedData ¶
func ExtendedData(children ...Element) *CompoundElement
ExtendedData returns a new ExtendedData element.
func Folder ¶
func Folder(children ...Element) *CompoundElement
Folder returns a new Folder element.
func GroundOverlay ¶
func GroundOverlay(children ...Element) *CompoundElement
GroundOverlay returns a new GroundOverlay element.
Example ¶
k := kml.KML( kml.Folder( kml.Name("Ground Overlays"), kml.Description("Examples of ground overlays"), kml.GroundOverlay( kml.Name("Large-scale overlay on terrain"), kml.Description("Overlay shows Mount Etna erupting on July 13th, 2001."), kml.Icon( kml.Href("https://developers.google.com/kml/documentation/images/etna.jpg"), ), kml.LatLonBox( kml.North(37.91904192681665), kml.South(37.46543388598137), kml.East(15.35832653742206), kml.West(14.60128369746704), kml.Rotation(-0.1556640799496235), ), ), ), ) 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"> <Folder> <name>Ground Overlays</name> <description>Examples of ground overlays</description> <GroundOverlay> <name>Large-scale overlay on terrain</name> <description>Overlay shows Mount Etna erupting on July 13th, 2001.</description> <Icon> <href>https://developers.google.com/kml/documentation/images/etna.jpg</href> </Icon> <LatLonBox> <north>37.91904192681665</north> <south>37.46543388598137</south> <east>15.35832653742206</east> <west>14.60128369746704</west> <rotation>-0.1556640799496235</rotation> </LatLonBox> </GroundOverlay> </Folder> </kml>
func GxAnimatedUpdate ¶
func GxAnimatedUpdate(children ...Element) *CompoundElement
GxAnimatedUpdate returns a new gx:AnimatedUpdate element.
func GxFlyTo ¶
func GxFlyTo(children ...Element) *CompoundElement
GxFlyTo returns a new gx:FlyTo element.
func GxKML ¶
func GxKML(children ...Element) *CompoundElement
GxKML returns a new kml element with Google Earth extensions.
func GxLatLonQuad ¶
func GxLatLonQuad(children ...Element) *CompoundElement
GxLatLonQuad returns a new gx:LatLonQuad element.
func GxMultiTrack ¶
func GxMultiTrack(children ...Element) *CompoundElement
GxMultiTrack returns a new gx:MultiTrack element.
func GxNetworkLink ¶
func GxNetworkLink(children ...Element) *CompoundElement
GxNetworkLink returns a new GxNetworkLink element.
func GxPlaylist ¶
func GxPlaylist(children ...Element) *CompoundElement
GxPlaylist returns a new gx:Playlist element.
func GxSimpleArrayField ¶
func GxSimpleArrayField(name, _type string) *CompoundElement
GxSimpleArrayField returns a new gx:SimpleArrayField element.
func GxSoundCue ¶
func GxSoundCue(children ...Element) *CompoundElement
GxSoundCue returns a new gx:SoundCue element.
func GxTour ¶
func GxTour(children ...Element) *CompoundElement
GxTour returns a new gx:Tour element.
func GxTourControl ¶
func GxTourControl(children ...Element) *CompoundElement
GxTourControl returns a new gx:TourControl element.
func GxTourPrimitive ¶
func GxTourPrimitive(children ...Element) *CompoundElement
GxTourPrimitive returns a new gx:TourPrimitive element.
func GxTrack ¶
func GxTrack(children ...Element) *CompoundElement
GxTrack returns a new gx:Track element.
func GxWait ¶
func GxWait(children ...Element) *CompoundElement
GxWait returns a new gx:Wait element.
func IconStyle ¶
func IconStyle(children ...Element) *CompoundElement
IconStyle returns a new IconStyle element.
func InnerBoundaryIs ¶
func InnerBoundaryIs(value Element) *CompoundElement
InnerBoundaryIs returns a new InnerBoundaryIs element.
func LabelStyle ¶
func LabelStyle(children ...Element) *CompoundElement
LabelStyle returns a new LabelStyle element.
func LatLonBox ¶
func LatLonBox(children ...Element) *CompoundElement
LatLonBox returns a new LatLonBox element.
func LineString ¶
func LineString(children ...Element) *CompoundElement
LineString returns a new LineString element.
Example ¶
k := kml.KML( kml.Document( kml.Name("Paths"), kml.Description("Examples of paths. Note that the tessellate tag is by default set to 0. If you want to create tessellated lines, they must be authored (or edited) directly in KML."), kml.SharedStyle( "yellowLineGreenPoly", kml.LineStyle( kml.Color(color.RGBA{R: 255, G: 255, B: 0, A: 127}), kml.Width(4), ), kml.PolyStyle( kml.Color(color.RGBA{R: 0, G: 255, B: 0, A: 127}), ), ), kml.Placemark( kml.Name("Absolute Extruded"), kml.Description("Transparent green wall with yellow outlines"), kml.StyleURL("#yellowLineGreenPoly"), kml.LineString( kml.Extrude(true), kml.Tessellate(true), kml.AltitudeMode("absolute"), kml.Coordinates([]kml.Coordinate{ {Lon: -112.2550785337791, Lat: 36.07954952145647, Alt: 2357}, {Lon: -112.2549277039738, Lat: 36.08117083492122, Alt: 2357}, {Lon: -112.2552505069063, Lat: 36.08260761307279, Alt: 2357}, {Lon: -112.2564540158376, Lat: 36.08395660588506, Alt: 2357}, {Lon: -112.2580238976449, Lat: 36.08511401044813, Alt: 2357}, {Lon: -112.2595218489022, Lat: 36.08584355239394, Alt: 2357}, {Lon: -112.2608216347552, Lat: 36.08612634548589, Alt: 2357}, {Lon: -112.262073428656, Lat: 36.08626019085147, Alt: 2357}, {Lon: -112.2633204928495, Lat: 36.08621519860091, Alt: 2357}, {Lon: -112.2644963846444, Lat: 36.08627897945274, Alt: 2357}, {Lon: -112.2656969554589, Lat: 36.08649599090644, Alt: 2357}, }...), ), ), ), ) 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"> <Document> <name>Paths</name> <description>Examples of paths. Note that the tessellate tag is by default set to 0. If you want to create tessellated lines, they must be authored (or edited) directly in KML.</description> <Style id="yellowLineGreenPoly"> <LineStyle> <color>7f00ffff</color> <width>4</width> </LineStyle> <PolyStyle> <color>7f00ff00</color> </PolyStyle> </Style> <Placemark> <name>Absolute Extruded</name> <description>Transparent green wall with yellow outlines</description> <styleUrl>#yellowLineGreenPoly</styleUrl> <LineString> <extrude>1</extrude> <tessellate>1</tessellate> <altitudeMode>absolute</altitudeMode> <coordinates>-112.2550785337791,36.07954952145647,2357 -112.2549277039738,36.08117083492122,2357 -112.2552505069063,36.08260761307279,2357 -112.2564540158376,36.08395660588506,2357 -112.2580238976449,36.08511401044813,2357 -112.2595218489022,36.08584355239394,2357 -112.2608216347552,36.08612634548589,2357 -112.262073428656,36.08626019085147,2357 -112.2633204928495,36.08621519860091,2357 -112.2644963846444,36.08627897945274,2357 -112.2656969554589,36.08649599090644,2357</coordinates> </LineString> </Placemark> </Document> </kml>
func LineStyle ¶
func LineStyle(children ...Element) *CompoundElement
LineStyle returns a new LineStyle element.
func LinearRing ¶
func LinearRing(children ...Element) *CompoundElement
LinearRing returns a new LinearRing element.
func ListStyle ¶
func ListStyle(children ...Element) *CompoundElement
ListStyle returns a new ListStyle element.
func LookAt ¶
func LookAt(children ...Element) *CompoundElement
LookAt returns a new LookAt element.
func MultiGeometry ¶
func MultiGeometry(children ...Element) *CompoundElement
MultiGeometry returns a new MultiGeometry element.
func NetworkLink ¶
func NetworkLink(children ...Element) *CompoundElement
NetworkLink returns a new NetworkLink element.
Example ¶
k := kml.KML( kml.Folder( kml.Name("Network Links"), kml.Visibility(false), kml.Open(false), kml.Description("Network link example 1"), kml.NetworkLink( kml.Name("Random Placemark"), kml.Visibility(false), kml.Open(false), kml.Description("A simple server-side script that generates a new random placemark on each call"), kml.RefreshVisibility(false), kml.FlyToView(false), kml.Link( kml.Href("http://yourserver.com/cgi-bin/randomPlacemark.py"), ), ), ), ) 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"> <Folder> <name>Network Links</name> <visibility>0</visibility> <open>0</open> <description>Network link example 1</description> <NetworkLink> <name>Random Placemark</name> <visibility>0</visibility> <open>0</open> <description>A simple server-side script that generates a new random placemark on each call</description> <refreshVisibility>0</refreshVisibility> <flyToView>0</flyToView> <Link> <href>http://yourserver.com/cgi-bin/randomPlacemark.py</href> </Link> </NetworkLink> </Folder> </kml>
func NetworkLinkControl ¶
func NetworkLinkControl(children ...Element) *CompoundElement
NetworkLinkControl returns a new NetworkLinkControl element.
func OuterBoundaryIs ¶
func OuterBoundaryIs(value Element) *CompoundElement
OuterBoundaryIs returns a new OuterBoundaryIs element.
func Placemark ¶
func Placemark(children ...Element) *CompoundElement
Placemark returns a new Placemark element.
Example ¶
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>
func PolyStyle ¶
func PolyStyle(children ...Element) *CompoundElement
PolyStyle returns a new PolyStyle element.
func Polygon ¶
func Polygon(children ...Element) *CompoundElement
Polygon returns a new Polygon element.
Example ¶
k := kml.KML( kml.Placemark( kml.Name("The Pentagon"), kml.Polygon( kml.Extrude(true), kml.AltitudeMode("relativeToGround"), kml.OuterBoundaryIs( kml.LinearRing( kml.Coordinates([]kml.Coordinate{ {Lon: -77.05788457660967, Lat: 38.87253259892824, Alt: 100}, {Lon: -77.05465973756702, Lat: 38.87291016281703, Alt: 100}, {Lon: -77.0531553685479, Lat: 38.87053267794386, Alt: 100}, {Lon: -77.05552622493516, Lat: 38.868757801256, Alt: 100}, {Lon: -77.05844056290393, Lat: 38.86996206506943, Alt: 100}, {Lon: -77.05788457660967, Lat: 38.87253259892824, Alt: 100}, }...), ), ), kml.InnerBoundaryIs( kml.LinearRing( kml.Coordinates([]kml.Coordinate{ {Lon: -77.05668055019126, Lat: 38.87154239798456, Alt: 100}, {Lon: -77.05542625960818, Lat: 38.87167890344077, Alt: 100}, {Lon: -77.05485125901023, Lat: 38.87076535397792, Alt: 100}, {Lon: -77.05577677433152, Lat: 38.87008686581446, Alt: 100}, {Lon: -77.05691162017543, Lat: 38.87054446963351, Alt: 100}, {Lon: -77.05668055019126, Lat: 38.87154239798456, Alt: 100}, }...), ), ), ), ), ) 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>The Pentagon</name> <Polygon> <extrude>1</extrude> <altitudeMode>relativeToGround</altitudeMode> <outerBoundaryIs> <LinearRing> <coordinates>-77.05788457660967,38.87253259892824,100 -77.05465973756702,38.87291016281703,100 -77.0531553685479,38.87053267794386,100 -77.05552622493516,38.868757801256,100 -77.05844056290393,38.86996206506943,100 -77.05788457660967,38.87253259892824,100</coordinates> </LinearRing> </outerBoundaryIs> <innerBoundaryIs> <LinearRing> <coordinates>-77.05668055019126,38.87154239798456,100 -77.05542625960818,38.87167890344077,100 -77.05485125901023,38.87076535397792,100 -77.05577677433152,38.87008686581446,100 -77.05691162017543,38.87054446963351,100 -77.05668055019126,38.87154239798456,100</coordinates> </LinearRing> </innerBoundaryIs> </Polygon> </Placemark> </kml>
func Region ¶
func Region(children ...Element) *CompoundElement
Region returns a new Region element.
func SchemaData ¶
func SchemaData(schemaURL string, children ...Element) *CompoundElement
SchemaData returns a new SchemaData element.
func ScreenOverlay ¶
func ScreenOverlay(children ...Element) *CompoundElement
ScreenOverlay returns a new ScreenOverlay element.
Example ¶
k := kml.KML( kml.ScreenOverlay( kml.Name("Absolute Positioning: Top left"), kml.Icon( kml.Href("http://developers.google.com/kml/documentation/images/top_left.jpg"), ), kml.OverlayXY(kml.Vec2{X: 0, Y: 1, XUnits: "fraction", YUnits: "fraction"}), kml.ScreenXY(kml.Vec2{X: 0, Y: 1, XUnits: "fraction", YUnits: "fraction"}), kml.RotationXY(kml.Vec2{X: 0, Y: 0, XUnits: "fraction", YUnits: "fraction"}), kml.Size(kml.Vec2{X: 0, Y: 0, XUnits: "fraction", YUnits: "fraction"}), ), ) 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"> <ScreenOverlay> <name>Absolute Positioning: Top left</name> <Icon> <href>http://developers.google.com/kml/documentation/images/top_left.jpg</href> </Icon> <overlayXY x="0" y="1" xunits="fraction" yunits="fraction"></overlayXY> <screenXY x="0" y="1" xunits="fraction" yunits="fraction"></screenXY> <rotationXY x="0" y="0" xunits="fraction" yunits="fraction"></rotationXY> <size x="0" y="0" xunits="fraction" yunits="fraction"></size> </ScreenOverlay> </kml>
func SimpleField ¶
func SimpleField(name, _type string, children ...Element) *CompoundElement
SimpleField returns a new SimpleField element.
func Style ¶
func Style(children ...Element) *CompoundElement
Style returns a new Style element.
Example ¶
k := kml.KML( kml.Document( kml.SharedStyle( "transBluePoly", kml.LineStyle( kml.Width(1.5), ), kml.PolyStyle( kml.Color(color.RGBA{R: 0, G: 0, B: 255, A: 125}), ), ), kml.Placemark( kml.Name("Building 41"), kml.StyleURL("#transBluePoly"), kml.Polygon( kml.Extrude(true), kml.AltitudeMode("relativeToGround"), kml.OuterBoundaryIs( kml.LinearRing( kml.Coordinates([]kml.Coordinate{ {Lon: -122.0857412771483, Lat: 37.42227033155257, Alt: 17}, {Lon: -122.0858169768481, Lat: 37.42231408832346, Alt: 17}, {Lon: -122.085852582875, Lat: 37.42230337469744, Alt: 17}, {Lon: -122.0858799945639, Lat: 37.42225686138789, Alt: 17}, {Lon: -122.0858860101409, Lat: 37.4222311076138, Alt: 17}, {Lon: -122.0858069157288, Lat: 37.42220250173855, Alt: 17}, {Lon: -122.0858379542653, Lat: 37.42214027058678, Alt: 17}, {Lon: -122.0856732640519, Lat: 37.42208690214408, Alt: 17}, {Lon: -122.0856022926407, Lat: 37.42214885429042, Alt: 17}, {Lon: -122.0855902778436, Lat: 37.422128290487, Alt: 17}, {Lon: -122.0855841672237, Lat: 37.42208171967246, Alt: 17}, {Lon: -122.0854852065741, Lat: 37.42210455874995, Alt: 17}, {Lon: -122.0855067264352, Lat: 37.42214267949824, Alt: 17}, {Lon: -122.0854430712915, Lat: 37.42212783846172, Alt: 17}, {Lon: -122.0850990714904, Lat: 37.42251282407603, Alt: 17}, {Lon: -122.0856769818632, Lat: 37.42281815323651, Alt: 17}, {Lon: -122.0860162273783, Lat: 37.42244918858722, Alt: 17}, {Lon: -122.0857260327004, Lat: 37.42229239604253, Alt: 17}, {Lon: -122.0857412771483, Lat: 37.42227033155257, Alt: 17}, }...), ), ), ), ), ), ) 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"> <Document> <Style id="transBluePoly"> <LineStyle> <width>1.5</width> </LineStyle> <PolyStyle> <color>7dff0000</color> </PolyStyle> </Style> <Placemark> <name>Building 41</name> <styleUrl>#transBluePoly</styleUrl> <Polygon> <extrude>1</extrude> <altitudeMode>relativeToGround</altitudeMode> <outerBoundaryIs> <LinearRing> <coordinates>-122.0857412771483,37.42227033155257,17 -122.0858169768481,37.42231408832346,17 -122.085852582875,37.42230337469744,17 -122.0858799945639,37.42225686138789,17 -122.0858860101409,37.4222311076138,17 -122.0858069157288,37.42220250173855,17 -122.0858379542653,37.42214027058678,17 -122.0856732640519,37.42208690214408,17 -122.0856022926407,37.42214885429042,17 -122.0855902778436,37.422128290487,17 -122.0855841672237,37.42208171967246,17 -122.0854852065741,37.42210455874995,17 -122.0855067264352,37.42214267949824,17 -122.0854430712915,37.42212783846172,17 -122.0850990714904,37.42251282407603,17 -122.0856769818632,37.42281815323651,17 -122.0860162273783,37.42244918858722,17 -122.0857260327004,37.42229239604253,17 -122.0857412771483,37.42227033155257,17</coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> </Document> </kml>
func StyleMap ¶
func StyleMap(children ...Element) *CompoundElement
StyleMap returns a new StyleMap element.
func TimeSpan ¶
func TimeSpan(children ...Element) *CompoundElement
TimeSpan returns a new TimeSpan element.
func TimeStamp ¶
func TimeStamp(children ...Element) *CompoundElement
TimeStamp returns a new TimeStamp element.
func (*CompoundElement) Add ¶
func (ce *CompoundElement) Add(children ...Element) *CompoundElement
Add adds children to ce.
func (*CompoundElement) MarshalXML ¶
func (ce *CompoundElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML marshals ce to e. start is ignored.
func (*CompoundElement) Write ¶
func (ce *CompoundElement) Write(w io.Writer) error
Write writes an XML header and ce to w.
func (*CompoundElement) WriteIndent ¶
func (ce *CompoundElement) WriteIndent(w io.Writer, prefix, indent string) error
WriteIndent writes an XML header and ce to w.
type Coordinate ¶
type Coordinate struct {
Lon, Lat, Alt float64
}
A Coordinate represents a single geographical coordinate. Lon and Lat are in degrees, Alt is in meters.
type CoordinatesArrayElement ¶
type CoordinatesArrayElement struct {
// contains filtered or unexported fields
}
CoordinatesArrayElement is a coordinates element.
func CoordinatesArray ¶
func CoordinatesArray(value ...[]float64) *CoordinatesArrayElement
CoordinatesArray returns a new CoordinatesArrayElement.
func (*CoordinatesArrayElement) MarshalXML ¶
func (cae *CoordinatesArrayElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML marshals cae to e. start is ignored.
func (*CoordinatesArrayElement) Write ¶
func (cae *CoordinatesArrayElement) Write(w io.Writer) error
Write writes an XML header and cae to w.
func (*CoordinatesArrayElement) WriteIndent ¶
func (cae *CoordinatesArrayElement) WriteIndent(w io.Writer, prefix, indent string) error
WriteIndent writes an XML header and cae to w.
type CoordinatesElement ¶
type CoordinatesElement struct {
// contains filtered or unexported fields
}
CoordinatesElement is a coordinates element.
func Coordinates ¶
func Coordinates(value ...Coordinate) *CoordinatesElement
Coordinates returns a new CoordinatesElement.
func (*CoordinatesElement) MarshalXML ¶
func (ce *CoordinatesElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML marshals ce to e. start is ignored.
func (*CoordinatesElement) Write ¶
func (ce *CoordinatesElement) Write(w io.Writer) error
Write writes an XML header and ce to w.
func (*CoordinatesElement) WriteIndent ¶
func (ce *CoordinatesElement) WriteIndent(w io.Writer, prefix, indent string) error
WriteIndent writes an XML header and ce to w.
type CoordinatesFlatElement ¶
type CoordinatesFlatElement struct {
// contains filtered or unexported fields
}
CoordinatesFlatElement is a coordinates element.
func CoordinatesFlat ¶
func CoordinatesFlat(flatCoords []float64, offset, end, stride, dim int) *CoordinatesFlatElement
CoordinatesFlat returns a new Coordinates element from flat coordinates.
func (*CoordinatesFlatElement) MarshalXML ¶
func (cfe *CoordinatesFlatElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML marshals cfe to e. start is ignored.
func (*CoordinatesFlatElement) Write ¶
func (cfe *CoordinatesFlatElement) Write(w io.Writer) error
Write writes an XML header and cfe to w.
func (*CoordinatesFlatElement) WriteIndent ¶
func (cfe *CoordinatesFlatElement) WriteIndent(w io.Writer, prefix, indent string) error
WriteIndent writes an XML header and cfe to w.
type Element ¶
type Element interface { xml.Marshaler Write(io.Writer) error WriteIndent(io.Writer, string, string) error }
An Element represents an abstract KML element.
type SharedElement ¶
type SharedElement struct { // contains filtered or unexported fields }
A SharedElement is an element with an id.
func Schema ¶
func Schema(id, name string, children ...Element) *SharedElement
Schema returns a new Schema element.
func SharedStyle ¶
func SharedStyle(id string, children ...Element) *SharedElement
SharedStyle returns a new shared Style element.
func SharedStyleMap ¶
func SharedStyleMap(id string, children ...Element) *SharedElement
SharedStyleMap returns a new shared StyleMap element.
type SimpleElement ¶
type SimpleElement struct { xml.StartElement // contains filtered or unexported fields }
A SimpleElement is an Element with a single value.
func Altitude ¶
func Altitude(value float64) *SimpleElement
Altitude returns a new Altitude element.
func AltitudeMode ¶
func AltitudeMode(value string) *SimpleElement
AltitudeMode returns a new AltitudeMode element.
func BgColor ¶
func BgColor(value color.Color) *SimpleElement
BgColor returns a new BgColor element.
func ColorMode ¶
func ColorMode(value string) *SimpleElement
ColorMode returns a new ColorMode element.
func Description ¶
func Description(value string) *SimpleElement
Description returns a new Description element.
Example ¶
k := kml.KML( kml.Document( kml.Placemark( kml.Name("CDATA example"), kml.Description(`<h1>CDATA Tags are useful!</h1> <p><font color="red">Text is <i>more readable</i> and <b>easier to write</b> when you can avoid using entity references.</font></p>`), kml.Point( kml.Coordinates(kml.Coordinate{Lon: 102.595626, Lat: 14.996729}), ), ), ), ) 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"> <Document> <Placemark> <name>CDATA example</name> <description><h1>CDATA Tags are useful!</h1> <p><font color="red">Text is <i>more readable</i> and <b>easier to write</b> when you can avoid using entity references.</font></p></description> <Point> <coordinates>102.595626,14.996729</coordinates> </Point> </Placemark> </Document> </kml>
func DisplayName ¶
func DisplayName(value string) *SimpleElement
DisplayName returns a new DisplayName element.
func DrawOrder ¶
func DrawOrder(value int) *SimpleElement
DrawOrder returns a new DrawOrder element.
func FlyToView ¶
func FlyToView(value bool) *SimpleElement
FlyToView returns a new FlyToView element.
func GxAltitudeMode ¶
func GxAltitudeMode(value string) *SimpleElement
GxAltitudeMode returns a new gx:AltitudeMode element.
func GxAltitudeOffset ¶
func GxAltitudeOffset(value float64) *SimpleElement
GxAltitudeOffset returns a new gx:AltitudeOffset element.
func GxAngles ¶
func GxAngles(value GxAngle) *SimpleElement
GxAngles returns a new gx:Angles element.
func GxBalloonVisibility ¶
func GxBalloonVisibility(value bool) *SimpleElement
GxBalloonVisibility returns a new gx:BalloonVisibility element.
func GxCoord ¶
func GxCoord(value Coordinate) *SimpleElement
GxCoord returns a new gx:Coord element.
func GxDelayedStart ¶
func GxDelayedStart(value float64) *SimpleElement
GxDelayedStart returns a new gx:DelayedStart element.
func GxDuration ¶
func GxDuration(value float64) *SimpleElement
GxDuration returns a new gx:Duration element.
func GxLabelVisibility ¶
func GxLabelVisibility(value bool) *SimpleElement
GxLabelVisibility returns a new gx:LabelVisibility element.
func GxOuterColor ¶
func GxOuterColor(value color.Color) *SimpleElement
GxOuterColor returns a new gx:OuterColor element.
func GxOuterWidth ¶
func GxOuterWidth(value float64) *SimpleElement
GxOuterWidth returns a new gx:OuterWidth element.
func GxPhysicalWidth ¶
func GxPhysicalWidth(value float64) *SimpleElement
GxPhysicalWidth returns a new gx:PhysicalWidth element.
func HTTPQuery ¶
func HTTPQuery(value string) *SimpleElement
HTTPQuery returns a new HTTPQuery element.
func Latitude ¶
func Latitude(value float64) *SimpleElement
Latitude returns a new Latitude element.
func LinkDescription ¶
func LinkDescription(value string) *SimpleElement
LinkDescription returns a new LinkDescription element.
func LinkSnippet ¶
func LinkSnippet(maxLines int, value string) *SimpleElement
LinkSnippet returns a new LinkSnippet element.
func ListItemType ¶
func ListItemType(value string) *SimpleElement
ListItemType returns a new ListItemType element.
func Longitude ¶
func Longitude(value float64) *SimpleElement
Longitude returns a new Longitude element.
func MaxAltitude ¶
func MaxAltitude(value float64) *SimpleElement
MaxAltitude returns a new MaxAltitude element.
func MaxFadeExtent ¶
func MaxFadeExtent(value int) *SimpleElement
MaxFadeExtent returns a new MaxFadeExtent element.
func MaxLodPixel ¶
func MaxLodPixel(value int) *SimpleElement
MaxLodPixel returns a new MaxLodPixel element.
func MinAltitude ¶
func MinAltitude(value float64) *SimpleElement
MinAltitude returns a new MinAltitude element.
func MinFadeExtent ¶
func MinFadeExtent(value int) *SimpleElement
MinFadeExtent returns a new MinFadeExtent element.
func MinLodPixel ¶
func MinLodPixel(value int) *SimpleElement
MinLodPixel returns a new MinLodPixel element.
func OverlayXY ¶
func OverlayXY(value Vec2) *SimpleElement
OverlayXY returns a new OverlayXY element.
func PhoneNumber ¶
func PhoneNumber(value string) *SimpleElement
PhoneNumber returns a new PhoneNumber element.
func RefreshInterval ¶
func RefreshInterval(value float64) *SimpleElement
RefreshInterval returns a new RefreshInterval element.
func RefreshMode ¶
func RefreshMode(value string) *SimpleElement
RefreshMode returns a new RefreshMode element.
func RefreshVisibility ¶
func RefreshVisibility(value bool) *SimpleElement
RefreshVisibility returns a new RefreshVisibility element.
func Rotation ¶
func Rotation(value float64) *SimpleElement
Rotation returns a new Rotation element.
func RotationXY ¶
func RotationXY(value Vec2) *SimpleElement
RotationXY returns a new RotationXY element.
func SimpleData ¶
func SimpleData(name, value string) *SimpleElement
SimpleData returns a new SimpleData element.
func TargetHref ¶
func TargetHref(value string) *SimpleElement
TargetHref returns a new TargetHref element.
func Tessellate ¶
func Tessellate(value bool) *SimpleElement
Tessellate returns a new Tessellate element.
func ViewBoundScale ¶
func ViewBoundScale(value float64) *SimpleElement
ViewBoundScale returns a new ViewBoundScale element.
func ViewFormat ¶
func ViewFormat(value string) *SimpleElement
ViewFormat returns a new ViewFormat element.
func ViewRefreshMode ¶
func ViewRefreshMode(value string) *SimpleElement
ViewRefreshMode returns a new ViewRefreshMode element.
func ViewRefreshTime ¶
func ViewRefreshTime(value float64) *SimpleElement
ViewRefreshTime returns a new ViewRefreshTime element.
func Visibility ¶
func Visibility(value bool) *SimpleElement
Visibility returns a new Visibility element.
func (*SimpleElement) MarshalXML ¶
func (se *SimpleElement) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML marshals se to e. start is ignored.
func (*SimpleElement) Write ¶
func (se *SimpleElement) Write(w io.Writer) error
Write writes an XML header and se to w.
func (*SimpleElement) WriteIndent ¶
func (se *SimpleElement) WriteIndent(w io.Writer, prefix, indent string) error
WriteIndent writes an XML header and se to w.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
hike-and-fly-route-kml
hike-and-fly-route prints a KML file of the route of popular races.
|
hike-and-fly-route prints a KML file of the route of popular races. |
Package icon provides helper functions for standard Google Earth icons.
|
Package icon provides helper functions for standard Google Earth icons. |
Package sphere contains convenience methods for generating coordinates on a sphere.
|
Package sphere contains convenience methods for generating coordinates on a sphere. |