-1

I would like to embed this to my windows form.

Private Sub InitializeComponent()
    Try
        Me.VirtualView = New WebBrowser
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(347, 261)
        Me.Name = "frmVirtual"
        Me.Text = "frmVirtual"
        Me.VirtualView.ScriptErrorsSuppressed = True
        Me.VirtualView.Name = "frmVirtual"
        Me.VirtualView.DocumentText = "<html><body><iframe width='600' height='450' style='border: 0' src='https://www.google.com/maps/embed?pb=!1m0!3m2!1sen!2sau!4v1481252003737!6m8!1m7!1sF%3A-pwYGx-oWTIk%2FWC6LeJuIxdI%2FAAAAAAAABIg%2FphppDvMZr54JiWnLbsbUgDcTGUfGXLMRACLIB!2m2!1d-33.76525136331761!2d150.9088391438127!3f310!4f0!5f0.7820865974627469' frameborder='0' allowfullscreen></iframe></body></html>"

    Catch ex As Exception

        MessageBox.Show(ex.Message.ToString(), "Unable to Retrieve")

    End Try

End Sub

But nothing displays on this code. Please help. Thank you.

Jen143
  • 815
  • 4
  • 17
  • 42
  • Have you **tried your proposed solution**? If not try it out... – Trevor Dec 09 '16 at 03:37
  • I have modified my question. – Jen143 Dec 09 '16 at 04:18
  • Please do not keep adding to your question, the issue you were facing was showing an `iframe` I helped with that. Adding to the question makes it much harder for people experiencing the same issue hard to find the correct answer. As always if you found the solution to help please vote. – Trevor Dec 09 '16 at 05:14

1 Answers1

0

You should not be navigating the address in the InitializeComponent method, use the Load() method of the class to navigate. for this particular issue you need to set the DocumentText property of the WebBrowser control.

On another note you are creating a new instance of the WebBrowser control, but are not adding it anywhere I could see. If you don't add it you will never see this control. IMO just drag and drop a new one where you need it.

Me.VirtualView.ScriptErrorsSuppressed = True
Me.VirtualView.DocumentText = "<html><body><iframe width='600' height='450' style='border: 0' src='https://www.google.com/maps/embed?pb=!1m0!3m2!1sen!2sau!4v1481252003737!6m8!1m7!1sF%3A-pwYGx-oWTIk%2FWC6LeJuIxdI%2FAAAAAAAABIg%2FphppDvMZr54JiWnLbsbUgDcTGUfGXLMRACLIB!2m2!1d-33.76525136331761!2d150.9088391438127!3f310!4f0!5f0.7820865974627469' frameborder='0' allowfullscreen></iframe></body></html>"

What I did here was you need to wrap the iframe inside a html and body tags.

Note: I added the ScriptErrorsSuppressed to true because there are script error's when loading that. Also look into the new way to embed these maps, they require an API key to use in your calls here

Trevor
  • 7,777
  • 6
  • 31
  • 50
  • I mentioned that, there are script error's when loading that not the code itself rather Google... To test this just replace src with `src='https://www.google.com'`... if it loads the code works. – Trevor Dec 09 '16 at 05:01
  • I tested my solution with another site and it work's just fine, not sure why it works without the `body` tags for you. Here I do not see anything on the source you provided... – Trevor Dec 09 '16 at 05:10
  • I have updated my codes. Can you see if it is correct? – Jen143 Dec 09 '16 at 05:13
  • You dont need any of that; much of it is wrong anyways, I explained that. Drop a new `WebBrowser` control on your form or usercontrol, that's it. – Trevor Dec 09 '16 at 05:17
  • Nothing display – Jen143 Dec 09 '16 at 05:39
  • I said that already its the map ***not the code***. `Me.VirtualView.DocumentText = "" ` use this and tell me it doesn't work... Drop a ***new WebBroswer*** control on your form, name it the same name you have been using. Double click your form and put the code above in the `Load`. I've ran this more than a few times... – Trevor Dec 09 '16 at 05:42