我正在尝试从文件中添加多个标记位置纬度和经度。但是只添加了一个标记,而且该标记也在错误的位置。以下是我的代码,我在哪里做错了?我正在以 Windows 形式使用 gmap.net
private void button1_Click(object sender, EventArgs e)
{
string start = "Pune, Maharashtra, India";// textBox1.Text;
string end = "Mumbai, Maharahtra, India"; //textBox2.Text;
GDirections ss;
var xx = GMapProviders.GoogleMap.GetDirections(out ss, start, end, false, false, false, false, false);
GMapRoute r = new GMapRoute(ss.Route, "My route");
GMapOverlay routesOverlay = new GMapOverlay("routes");
r.Stroke.Width = 2;
r.Stroke.Color = Color.Black;
routesOverlay.Routes.Add(r);
gmap.Overlays.Add(routesOverlay);
//marker adding POI
if (comboBox1.SelectedIndex == 0)
{
// MessageBox.Show("hotels");
string line;
GMapOverlay markersOverlay = new GMapOverlay("markers");
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader("D:\\hotels_lat_long"); // db file
while ((line = file.ReadLine()) != null)
{
string[] Data_Array = line.Split(',');
Double londecimal = Convert.ToDouble(Data_Array[0]);
Double latdecimal = Convert.ToDouble(Data_Array[1]);
//add a new one here
var marker = new GMarkerGoogle(new PointLatLng(latdecimal, londecimal), GMarkerGoogleType.green);
marker.IsVisible = true;
markersOverlay.Markers.Add(marker);
gmap.Overlays.Add(markersOverlay);
}
file.Close();
}
if (comboBox1.SelectedIndex == 1)
{
//MessageBox.Show("Fuel Pumps");
}
}