4

嗨,我有 1000 个纬度、经度,想在地图上显示所有这些。我尝试了几种方法来做到这一点,但没有运气.....我有一个数据网格视图,它有客户端、纬度、经度、区域。每个客户端都有一个区域。当我单击组合框区域 1 时,我有一个组合框,它应该在地图上显示区域 1 上的所有客户端,这可能吗?请帮忙。

if (comboBox5.SelectedIndex == 0)//(REGION 1)
{
    String Query = " SELECT top  Latitude,Longitude  FROM[ICPS].[dbo].[Sheet3_kir]   ";
    SqlCommand cmdDatabase = new SqlCommand(Query, conDatabase);
    SqlDataReader myReader;
    gMapControl1.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
    GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;

    GMapOverlay markersOverlay = new GMapOverlay("VCS MAP");
    //gMapControl1.Overlays.Add(markersOverlay); 

    for (int i = 0; i <= dataGridView1.Rows.Count; i++)
    {
        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            var Latitude = double.Parse(dataGridView1.Columns[1].ToString());
            var Longitude = double.Parse(dataGridView1.Columns[2].ToString());
            gMapControl1.Position = new PointLatLng(Latitude, Longitude);
            // GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(float.Parse(this.dataGridView1.Columns[1].ToString), float.Parse(this.textBox26.Text)),
            // GMarkerGoogleType.green);
            GMarkerGoogle m = new GMarkerGoogle(gMapControl1.Position, GMarkerGoogleType.green_pushpin);
            //markersOverlay.Markers.Add(m);
        }
    }
4

2 回答 2

0
            MySqlDataAdapter da = new MySqlDataAdapter("select * from sinkhole where sinkhole_status = '" + "Active" + "'", Conn);
            MySqlCommandBuilder cBuilder = new MySqlCommandBuilder(da);

            DataTable dataTable = new DataTable();
            DataSet ds = new DataSet();
            da.Fill(dataTable);

            for (int i = dataTable.Rows.Count - 1; i >= 0; i--)
            {
                double lng = double.Parse(dataTable.Rows[i][4].ToString());
                double lat = double.Parse(dataTable.Rows[i][3].ToString());
                string location = dataTable.Rows[i][2].ToString();
                string name = dataTable.Rows[i][1].ToString();
                string desciption = dataTable.Rows[i][5].ToString();

                GMapOverlay markersOverlay = new GMapOverlay(map, "marker");
                GMapMarkerGoogleGreen marker = new GMapMarkerGoogleGreen(new PointLatLng(lat, lng));
                markersOverlay.Markers.Add(marker);
                //marker.ToolTipMode = MarkerTooltipMode.Always;
                marker.ToolTip = new GMapRoundedToolTip(marker);
                marker.ToolTipText = "Coordinates: (" + Convert.ToString(lat) + "," + Convert.ToString(lng) + ")" + "\nLocation: " + location + "\nName: " + name;
                map.Overlays.Add(markersOverlay);
于 2015-01-19T15:46:41.530 回答
0
 for (int i = 0; i < dataGridView1.Rows.Count; ++i)
      {
        double lat = Convert.ToDouble(dataGridView1.Rows[i].Cells[9].Value) ; 
        double    lng = Convert.ToDouble(dataGridView1.Rows[i].Cells[10].Value);
           string Vehicle = Convert.ToString(dataGridView1.Rows[i].Cells[5].Value);
           string name = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value);
        string   Adress = Convert.ToString(dataGridView1.Rows[i].Cells[2].Value);

            MapaContr.MapProvider = GMapProviders.GoogleHybridMap;

            GMapOverlay markersOverlay = new GMapOverlay("markers");
            GMarkerGoogle marker = new GMarkerGoogle(new PointLatLng(lat, lng), GMarkerGoogleType.lightblue);
            markersOverlay.Markers.Add(marker);
           marker.ToolTipMode = MarkerTooltipMode.Always;
            marker.ToolTip = new GMapRoundedToolTip(marker);
            marker.ToolTipText =  "Adress: " + Adress + "\nIme: " + name + "\nVehicle:" + Vehicle   ;
            MapaContr.Overlays.Add(markersOverlay);

我从 MySql 数据库和 datagridView(dataGridView1) 解决方案中获得了 Gmap 上的多个标记的解决方案。它非常精确且易于管理。

于 2022-02-28T14:35:20.873 回答