这是我的代码
public static void generar_kml(DataTable data_gps)
{
var document = new Document();
var kml = new Kml();
Placemark placemarks;
Point Punto_gps;
foreach (DataRow datatable in data_gps.Rows)
{
Punto_gps = new Point();
Punto_gps.Coordinate = new
Vector(double.Parse(datatable["Long"].ToString()),
double.Parse(datatable["Lat"].ToString()));
placemarks = new Placemark();
placemarks.Name = datatable["Place"].ToString();
placemarks.Geometry = Punto_gps;
kml.Feature = placemarks;
}
Serializer serializer = new Serializer();
serializer.Serialize(kml);
Console.WriteLine(serializer.Xml);
Console.ReadKey();
}
这是输出;
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Name of place</name>
<Point>
<coordinates>-84.135109999999997,9.9416100000000007</coordinates>
</Point>
</Placemark>
</kml>"
答案 0 :(得分:1)
您需要添加document.AddFeature(placemarks);在foreach里面。您不需要kml.feature行。