package kml import ( "bytes" "fmt" "github.com/tidwall/tile38/geojson" ) type pointT struct { name string point geojson.SimplePoint } type KML struct { points []pointT } func New() *KML { return &KML{} } func (kml *KML) AddPoint(name string, lat, lon float64) { kml.points = append(kml.points, pointT{name: name, point: geojson.SimplePoint{X: lon, Y: lat}}) } func (kml *KML) Bytes() []byte { var buf bytes.Buffer buf.WriteString(`` + "\n") buf.WriteString(`` + "\n") buf.WriteString(`` + "\n") buf.WriteString(` ` + "\n") buf.WriteString(` ` + "\n") for _, point := range kml.points { buf.WriteString(fmt.Sprintf(`#yellow%s%f,%f,0`+"\n", point.name, point.point.X, point.point.Y)) } buf.WriteString(`` + "\n") return buf.Bytes() }