Google Map API - How to map an address on a map in a VB Win Forms application

This piece of code will show you how to create a form that has a Google map in it.

You'll need to drop a 'WebBrowserControl' onto your form

 

Related Articles

... and you 'll find more on the NET Development Menu

    ''' <summary>
    ''' Map a physical address
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub MapIt(strAddress1 As String, strCity As String, strState As String, strZip As String)
 
        Try
            Dim queryAddress As New StringBuilder()
            queryAddress.Append("http://maps.google.com/maps?q=")
 
            ' build street part of query string
            If strAddress1 <> String.Empty Then
                queryAddress.Append(strAddress1.Replace(" ""+") + "," & "+")
            End If
 
            ' build city part of query string
            If strCity <> String.Empty Then
                queryAddress.Append(strCity.Replace(" ""+") + "," & "+")
            End If
 
            ' build state part of query string
            If strState <> String.Empty Then
                queryAddress.Append(strState.Replace(" ""+") + "," & "+")
            End If
 
            ' build zip code part of query string
            If strZip <> String.Empty Then
                queryAddress.Append(strZip)
            End If
 
            ' pass the url with the query string to web browser control
            WebBrowser1.Navigate(queryAddress.ToString())
 
        Catch ex As Exception
 
            MessageBox.Show(ex.Message.ToString(), "Unable to Retrieve Map")
 
        End Try
 
    End Sub
    Private Sub Form1_Load(sender As Object, e As System.EventArgsHandles Me.Load
        MapIt("1082 MOORES MILL RD""ATLANTA""GA""30327")
    End Sub

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences