2

I am creating a database application using VB.net and MSSQL 2012. I have retrieved a list of customer from the database and want to plot them on google map. At it stands, I can only plot the first customer. Below is my code. Can someone help me out as this has been killing me for some times now.

    Dim lat As String = String.Empty
    Dim lon As String = String.Empty

    Dim queryAddress As New StringBuilder()
    queryAddress.Append("http://maps.google.com/maps?q=")

    For i = 0 To Me.DataGridView1.RowCount - 1
        If Me.DataGridView1.Rows(i).Cells(0).Value <> String.Empty Then
            lat = Me.DataGridView1.Rows(i).Cells(0).Value
            queryAddress.Append(lat + "%2C")
        End If

        If Me.DataGridView1.Rows(i).Cells(1).Value <> String.Empty Then
            lon = Me.DataGridView1.Rows(i).Cells(1).Value
            queryAddress.Append(lon)
        End If
        WebBrowser1.Navigate(queryAddress.ToString())
    Next
  • How is your geometry stored in MS-SQL 2012? – Mapperz Sep 16 '14 at 13:38
  • I am retrieving geography coordinates as integer (example Decimal Degree --> 6.3434, -10.2324) directly from the database. – Mahmoud Solomon Sep 16 '14 at 15:08
  • Create a Polygon around the point then intersect the polygon with any points inside it stackoverflow.com/questions/20653424/… – Mapperz Sep 16 '14 at 15:13
  • that is not working and display only last record data – Tms Sabry May 18 '18 at 14:40
2

I think this will work:

Dim queryAddress As New StringBuilder()
    queryAddress.Append("http://maps.google.com/maps?q=")

    For i = 0 To Me.DataGridView1.RowCount - 1
        If Me.DataGridView1.Rows(i).Cells(0).Value <> String.Empty Then
            lat = Me.DataGridView1.Rows(i).Cells(0).Value
            queryAddress.Append(lat + "%2C")
        End If

        If Me.DataGridView1.Rows(i).Cells(1).Value <> String.Empty Then
            lon = Me.DataGridView1.Rows(i).Cells(1).Value
            queryAddress.Append(lon)
        End If
        WebBrowser1.Navigate(queryAddress.ToString())
        i=i+1 
    Next

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.