I am trying to generate an image from a url and load it into a picturebox, but I keep getting an invalid parameter error on my URL. I am attempting to use google maps and had an entire map path, but dropped it down to just the maps URL and still getting the error. Can someone let me know what is wrong with my code:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'LoadWebImageToPictureBox(PictureBox1, "http://maps.google.com/?q=113+gunn+road" & Chr(44) & "+centerville" & Chr(44) & "+ga" & Chr(44) & "+31028&z=2&t=h")
Try
Dim req As Net.HttpWebRequest = DirectCast(Net.HttpWebRequest.Create("http://maps.google.com/?q=1113+watson+blvd,+warner+robins,+ga,+31028&z=2&t=h"), Net.HttpWebRequest)
Dim res As Net.HttpWebResponse = DirectCast(req.GetResponse, Net.HttpWebResponse)
Dim img As Image = Image.FromStream(res.GetResponseStream)
res.Close()
PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
PictureBox1.Image = img
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
PictureBox1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData("http://www.google.com/")))
End Sub