hi
I am using this code below to calculate the distance and time between 2 locations as answered in a previous question on here.
The thing is that i want to use textboxes on the form which is the postcode for the origin and destination but unable to get it to work correctly i believe it is due to needing to encode the textbox string to utf8 however don’t know how.
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim url As String = "https://maps.googleapis.com/maps/api/distancematrix/xml?origins=SE9%204QH&destinations=BR7%205QP&key=AIzaSyBojHBt73ZegOGb2Kj8boi0HXMKRyfftVg"
Dim request As WebRequest = WebRequest.Create(url)
Using response As WebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
Using reader As New StreamReader(response.GetResponseStream(), Encoding.UTF8)
Dim dsResult As New DataSet()
dsResult.ReadXml(reader)
lblOriginAddress.Text = dsResult.Tables("DistanceMatrixResponse").Rows(0)("origin_address").ToString()
lblDestinationAddress.Text = dsResult.Tables("DistanceMatrixResponse").Rows(0)("destination_address").ToString()
lblDurationText.Text = dsResult.Tables("duration").Rows(0)("text").ToString()
lblDurationValue.Text = dsResult.Tables("duration").Rows(0)("value").ToString()
lblDistanceText.Text = dsResult.Tables("distance").Rows(0)("text").ToString()
lblDistanceValue.Text = dsResult.Tables("distance").Rows(0)("value").ToString()
End Using
End Using
End Sub
the text boxes would be origintextbox and destinationtextbox on the form
help would be truely apreciated on this
thanks viddi