protected void Button1_Click(object sender, EventArgs e) { var document = new Document(); document.Id = "Document"; document.Name = "Document"; SharpKml.Dom.Style style = new SharpKml.Dom.Style(); style.Id = "yellowLineGreenPoly"; //style.Line = new LineStyle(new Color32(HexStringToColor("7f00ffff"),4)); //Color32 col = HexStringToColor("7f00ffff"); //LineStyle ls = new LineStyle(); //ls.Color = col; //style.Line = ls; //document.AddStyle(style); Description ds = new Description(); ds.Text = @"<h1>Car's Tracking</h1> "; LineString linestring = new LineString(); CoordinateCollection coordinates = new CoordinateCollection(); //Color clr = Color.FromArgb(100, 150, 75); //clr.ToArgb(); SqlConnection sqlcon = new SqlConnection(conStr); // String com = "select Latitude, Longitude from Coordinates where IMEI=@txtIMEI"; SqlCommand sqlcom = new SqlCommand("GetLatLon", sqlcon); sqlcom.CommandType = CommandType.StoredProcedure; sqlcom.Parameters.Add("@IMEI", SqlDbType.VarChar).Value= TextBox1.Text; DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(sqlcom); sda.Fill(dt); try { sqlcon.Open(); sqlcom.ExecuteNonQuery(); foreach (DataRow dr in dt.Rows) { double lon = double.Parse(dr["Longitude"].ToString()); double lat = double.Parse(dr["Latitude"].ToString()); coordinates.Add(new Vector(lat, lon)); } linestring.Coordinates = coordinates; Placemark placemark = new Placemark(); placemark.Name = "Car's Track Record"; placemark.Description = ds; // placemark.StyleUrl = new Uri("#yellowLineGreenPoly", UriKind.Relative); placemark.Geometry = linestring; document.AddFeature(placemark); // linestring.Extrude = true; linestring.Tessellate = true; linestring.AltitudeMode = AltitudeMode.RelativeToGround; var kml = new Kml(); // kml.Feature = document; kml.Feature = placemark; KmlFile kmlFile = KmlFile.Create(kml, true); using (var stream = System.IO.File.OpenWrite("C:/"+"IMEI-"+TextBox1.Text+".kmz")) { kmlFile.Save(stream); Response.Write("KML Created"); } } catch (Exception exc) { Response.Write(exc.Message); } finally { sqlcon.Close(); } }
linestring
document
kml
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)