我一直在用Winforms c#开发一个项目,我想使用来自CSV文件的实时输入数据来移动GMap控件上的标记。
我尝试了一些,代码如下:
cnn.Open();
SqlCommand cmd = new SqlCommand("Select
baro_altitude,longitude,latitude from HzTBB", cnn);
SqlDataReader reader = cmd.ExecuteReader();
double lat=0, lon=0;
while (reader.Read())
{
lat = Convert.ToDouble(reader.GetValue(2).ToString());
lon = Convert.ToDouble(reader.GetValue(1).ToString());
label3.Text = "Altitude : " + reader.GetValue(0).ToString();
}
gMapControl1.DragButton = MouseButtons.Left;
gMapControl1.MapProvider = GMapProviders.GoogleMap;
//double lat = Convert.ToDouble(textBox1.Text);
//double lon = Convert.ToDouble(textBox2.Text);
gMapControl1.Position = new PointLatLng(lat, lon);
gMapControl1.MinZoom = 1;
gMapControl1.MaxZoom = 100;
gMapControl1.Zoom = 10;
PointLatLng point = new PointLatLng(lat, lon);
GMapMarker marker = new GMarkerGoogle(point,
GMarkerGoogleType.red_dot);
GMapOverlay markers = new GMapOverlay("markers");
markers.Markers.Add(marker);
gMapControl1.Overlays.Add(markers);
cnn.Close();
标记没有移动,但显示了带有两个标记点的第一个和最后一个地址。