将datagridView中的数据输入到gMapControl中

时间:2017-02-03 21:20:20

标签: c# gmap.net

我在使用for key,value in arg_dict.items(): if not is_jsonable(value): keys_to_delete.append(key) 的数据编写C#时遇到了一些问题。

我在dataGridView上有一些数据表,我需要使用GMap.Net将此信息放入dataGridView,以便在地图上创建多个标记。

这是我的代码:

gMapControl

2 个答案:

答案 0 :(得分:0)

这是伪代码,应该让你去

var dgv = new DataGridView();
var str = dgv.Rows[0].Cells["Column Name here"]; //column name
var ord = dgv.Rows[0].Cells[0]; //column ordnal 

var changeableValue = string.Empty;
foreach (DataGridViewRow row in dgv.Rows)
{
    changeableValue = row.Cells[0].ToString(); // ordinal position again
}

答案 1 :(得分:0)

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
    
    GMapControl1.DragButton = Windows.Forms.MouseButtons.Left
    GMapControl1.CanDragMap = True

    If RadioButton1.Checked Then
        ' Form3.GMapControl1.MapProvider = GMapProviders.GoogleSatelliteMap
        Form3.GMapControl1.MapProvider = GMapProviders.GoogleHybridMap
    ElseIf RadioButton2.Checked Then
        Form3.GMapControl1.MapProvider = GMapProviders.GoogleMap
    ElseIf RadioButton3.Checked Then
        Form3.GMapControl1.MapProvider = GMapProviders.GoogleTerrainMap
    End If

    Form3.GMapControl1.Position = New PointLatLng(35.502509, 2.916693)
    Form3.GMapControl1.MinZoom = 0
    Form3.GMapControl1.MaxZoom = 24
    Form3.GMapControl1.Zoom = 7
    Form3.GMapControl1.Dock = DockStyle.Fill
    'GMapControl1.AutoScroll = True

    GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache


    For j As Integer = 0 To DataGridView1.Rows.Count - 2

        Dim marker As GMarkerGoogle = New GMarkerGoogle(New PointLatLng(DataGridView1.Rows(j).Cells(1).Value, DataGridView1.Rows(j).Cells(2).Value), GMarkerGoogleType.green)

        ' marker.ToolTipText = String.Format("réservoir " + DataGridView1.Rows(j).Cells(4).Value)
        marker.ToolTipText = String.Format("Réservoir " + DataGridView1.Rows(j).Cells(8).Value + " m3 " + DataGridView1.Rows(j).Cells(4).Value)
        markers.Markers.Add(marker)
        Form3.GMapControl1.Overlays.Add(markers)
        marker.ToolTipMode = MarkerTooltipMode.Always
    Next
    Return
End Sub