This project has moved. For the latest updates, please go here.

Help! Creating KML FILE

Dec 7, 2014 at 12:59 PM
Edited Dec 8, 2014 at 1:49 PM
I have a two problems ..
I'm using coordinates from DATAGRID, so i write some code..
it must me a cycle for every points
but. i have the only one in the end..
  for (int i = 0; i < dt.Rows.Count; i++)

                float Axis_X = (float)dt.Rows[i]["Axis_X"];
                float Axis_Y = (float)dt.Rows[i]["Axis_Y"];

                // This will be used for the placemark
                SharpKml.Dom.Point point = new SharpKml.Dom.Point();
                point.Coordinate = new SharpKml.Base.Vector(Axis_Y, Axis_X); 

                Placemark placemark = new Placemark();
                placemark.Geometry = point;
                placemark.Name = "7765"; 
                placemark.Id = "i";

                //// This is the root element of the file
                Kml kml = new Kml();
                kml.Feature = placemark;
                kml.Feature = placemark;

                KmlFile kmlfile = KmlFile.Create(kml, false);

                using (FileStream stream = File.OpenWrite("placemark.kml"))

And the second.. I need to create not only points, i need a lines, which must be creating from TWO PAIRS coordinates...
Please, help T-T
Dec 8, 2014 at 6:39 AM
Edited Dec 8, 2014 at 6:40 AM
For the first problem I think you are overwriting the same file in your loop, perhaps what you want to do is create a single Kml root element outside the loop that has a Document as its feature and then you can add the placemarks from the loop to the Document and save the file once outside the loop?

For the second problem, I think you can create a line with the LineString property on the Placemark.

Hope it helps,