Admin Admin


Posts : 140 Join date : 2011-08-01
 | Subject: vb.net google map Thu Aug 11, 2011 1:13 am | |
| add text boxes to hold street, city, state and zip Add search button add : in the code first line Imports System.Text in the button click event (double click it and paste) : - Code:
-
Try Dim streetaddr As String = "" Dim cityaddr As String = "" Dim stateaddr As String = "" Dim zipaddr As String = "" Dim AddrToSearch As New StringBuilder() AddrToSearch.Append("http://maps.google.com/maps?q=")
' if there is street entry If txtStreet.Text <> "" Then streetaddr = txtStreet.Text.Replace(" ", "+") AddrToSearch.Append(street + "," & "+") End If
' if there is city entry If txtCity.Text <> "" Then cityaddr = txtCity.Text.Replace(" ", "+") AddrToSearch.Append(city + "," & "+") End If
' if there is state If txtState.Text <> "" Then stateaddr = txtState.Text.Replace(" ", "+") AddrToSearch.Append(state + "," & "+") End If
' if there is zip code If txtZipCode.Text <> "" Then zipaddr = txtZipCode.Text.ToString() AddrToSearch.Append(zip) End If
' pass the AddrToSearch value to web browser control wbrowser.Navigate(AddrToSearch.ToString())
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Problem encountered while retrieving google map")
End Try search the map by latitude and longitude add theire textboxes and button in it's event paste : - Code:
-
Try Dim latitude As String = "" Dim longitude As String = "" Dim AddrToSearch As New StringBuilder() AddrToSearch.Append("http://maps.google.com/maps?q=")
' if there is latitude If txtLatitude.Text <> "" Then latitude = txtLatitude.Text AddrToSearch.Append(latitude & "%2C") End If
' if there is longitude If txtLongitude .Text <> "" Then longitude = txtLongitude .Text AddrToSearch.Append(longitude) End If
' pass the AddrToSearch value to web browser control wbrowser.Navigate(AddrToSearch.ToString())
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Problem encountered while retrieving google map")
End Try | |
|