Image from website

cpopham

Junior Contributor
Joined
Feb 18, 2004
Messages
273
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
 
I looked at that, but I am wanting to put the map in a picturebox on a winform, not an asp page, so that does not really help because it is for a web page. I had read a couple of articles that said you can convert the webpage to a bitmap and display it that way using a picturebox which is what I was attempting to do.

Chester
 
Back
Top