我想将其嵌入我的窗口。
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
,但没有在此代码上显示任何内容。请帮忙。谢谢。
您不应在InitializeComponent
方法中导航地址,请使用类的Load()
方法进行导航。对于此特定问题,您需要设置WebBrowser
控件的DocumentText
属性。
在另一个注释中,您正在创建WebBrowser
控件的新实例,但没有在我可以看到的任何地方添加它。如果不添加它,您将永远不会看到此控件。IMO只是拖放一个新的,您需要它。
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>"
我在这里所做的是,您需要将iframe
包装在html
和body
标签中。
note :我将ScriptErrorsSuppressed
添加到True中,因为加载该脚本错误。还要查看嵌入这些地图的新方法,它们需要一个API键才能在您的调用中使用此处