标签: sharpkml

在 C# 中样式化 KML 文件

我已经在 asp.net(C#) 中编写了 webapp,它从数据库中获取坐标并创建 .KML,然后我将其放入谷歌地图并工作正常,即绘制线串,但我想将样式放入其中,即更改地标样式、颜色,尺寸等。网上没有关于它的帮助。

代码:

using SharpKml.Base;
using SharpKml.Dom;
using SharpKml.Engine;


    protected void Button1_Click(object sender, EventArgs e)
    {
        var document = new Document();
        document.Id = "null";
        document.Name = "null";
        LineString linestring = new LineString();
         CoordinateCollection coordinates = new CoordinateCollection();

        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 …
Run Code Online (Sandbox Code Playgroud)

c# asp.net google-maps c#-4.0 sharpkml

6
推荐指数
1
解决办法
4944
查看次数

如何使用 SharpKml 创建 StyleMap 标签?

我想知道如何使用 SharpKml 创建以下 XML:

<StyleMap id="msn_placemark_circle">
    <Pair>
        <key>normal</key>
        <styleUrl>#sn_placemark_circle</styleUrl>
    </Pair>
    <Pair>
        <key>highlight</key>
        <styleUrl>#sh_placemark_circle_highlight</styleUrl>
    </Pair>
</StyleMap>
Run Code Online (Sandbox Code Playgroud)

我尝试了几件事,但没有成功。这是我到目前为止:

public static StyleSelector Generate_M_ylw_pushpin3()
{
    var stylemap = new StyleMapCollection();
    stylemap.Id = "s_ylw-pushpin3";
    var normalPair = new Pair();
    normalPair.Id = "normal";
    normalPair.Selector = StyleGenerator.Generate_s_ylw_pushpin_hl3();
    //normalPair.StyleUrl = new Uri(#sh_placemark_circle_highlight); // Exception by .NET

    var highlightPair = new Pair();
    highlightPair.Id = "highlight";
    highlightPair.Selector = StyleGenerator.Generate_s_ylw_pushpin_hl3();
    //highlightPair.StyleUrl = new Uri(#sh_placemark_circle_highlight); // Exception by .NET

    stylemap.Add(normalPair);
    stylemap.Add(highlightPair);

    return stylemap;
}

// This code just works fine
public static …
Run Code Online (Sandbox Code Playgroud)

c# kml sharpkml

5
推荐指数
1
解决办法
2286
查看次数

C#Generic List foreach OutofMemoryException

我有一个程序,从数据库中读取大约200万行到List.每行是包含地理坐标等信息的位置.

将数据添加到List后,我使用foreach循环并获取坐标以创建kml文件.当行数很大时,循环遇到OutOfMemoryException错误(但是否则完美地工作).

有关如何处理此问题的任何建议,以便程序可以处理非常大的数据集?kml库是SharpKML.

我还是C#的新手,所以请放轻松!

这是循环:

            using (SqlConnection conn = new SqlConnection(connstring))
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand(select, conn);

            using (cmd)
            {
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    double lat = reader.GetDouble(1);
                    double lon = reader.GetDouble(2);
                    string country = reader.GetString(3);
                    string county = reader.GetString(4);
                    double TIV = reader.GetDouble(5);
                    double cnpshare = reader.GetDouble(6);
                    double locshare = reader.GetDouble(7);

                    //Add results to list
                    results.Add(new data(lat, lon, country, county, TIV, cnpshare, locshare));
                }
                reader.Close();
            }
            conn.Close();
        }

            int count = results.Count();
            Console.WriteLine("number of …
Run Code Online (Sandbox Code Playgroud)

c# foreach out-of-memory generic-list sharpkml

3
推荐指数
1
解决办法
1549
查看次数