我正在使用Google地图控件DLL文件来创建Google地图应用程序,该应用程序使用C#ASP.NET显示来自我的SQL数据库的所有坐标点。我的问题是它显示标记,但不显示多段线以加入我的点。多段线不显示(谷歌地图)
这里是C#中的一段代码,获取的纬度,经度和标记的每个:
Here is the code:
double lat = 0;
double log = 0;
SqlConnection conn = new SqlConnection(sqlConStr);
SqlCommand cmd = new SqlCommand("SELECT Lat,Long FROM Tracks WHERE TrackID= @TrackID", conn);
cmd.Parameters.AddWithValue("@TrackID", addressType.SelectedValue);
SqlDataReader reader;
// Try to open database and read information.
try
{
conn.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
lat = Convert.ToDouble(reader[0].ToString());
log = Convert.ToDouble(reader[1].ToString());
GMap.Center = new LatLng(lat, log);
GMap.ZoomLevel= 12;
GMap.Add(new ImageMarker(GMap.Center, " ", new InfoWindow(""), "http://localhost/red.jpg"));
List<LatLng> Coord= new List<LatLng>();
Coord.Add(new LatLng(lat, log));
GMap.Add(new PolyLine(Coord, Color.Red, 100f, 2, new InfoWindow("")));
}
reader.Close();
}
catch (Exception err)
{
lblResults.Text = "Error Fetching ";
//err.Message;
}
finally
{
conn.Close();
}
}
由于提前。
你不如果只包含单个点,则绘制多段线。 – user7116
谢谢。我添加了一些固定坐标,它的工作原理,但我想从我的sql数据库中读取所有的纬度和经度,并将其添加到列表中,但这似乎并没有工作。任何想法请 – Fred
你应该包括导致问题的实际代码。 – user7116