Vb.net 嵌入谷歌商务视图虚拟旅游

Vb.net 嵌入谷歌商务视图虚拟旅游,vb.net,winforms,virtual-tour,Vb.net,Winforms,Virtual Tour,我想将其嵌入到我的windows窗体中 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

我想将其嵌入到我的windows窗体中

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
Private子初始化组件()
尝试
Me.VirtualView=新的网络浏览器
Me.AutoScaleDimensions=新系统.Drawing.SizeF(6.0!13.0!)
Me.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize=新系统.图纸.尺寸(347261)
Me.Name=“frmVirtual”
Me.Text=“frmVirtual”
Me.VirtualView.ScriptErrorsSuppressed=True
Me.VirtualView.Name=“frmVirtual”
Me.VirtualView.DocumentText=“”
特例
MessageBox.Show(例如Message.ToString(),“无法检索”)
结束尝试
端接头

但此代码上没有显示任何内容。请帮忙。谢谢。

您不应该在
InitializeComponent
方法中导航地址,请使用类的
Load()
方法进行导航。对于此特定问题,您需要设置
WebBrowser
控件的
DocumentText
属性

另一方面,您正在创建
WebBrowser
控件的新实例,但没有将其添加到我可以看到的任何地方。如果不添加它,您将永远不会看到此控件。我只是在你需要的地方拖放一个新的

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>"
Me.VirtualView.ScriptErrorsSuppressed=True
Me.VirtualView.DocumentText=“”
我在这里做的是,您需要将
iframe
包装在
html
body
标记中


注意:我将
脚本错误抑制
添加为true,因为加载时存在脚本错误。还要研究嵌入这些映射的新方法,它们需要API密钥才能在调用中使用

您是否尝试过建议的解决方案?如果不尝试…我已经修改了我的问题。请不要继续添加到您的问题中,您所面临的问题显示了一个
iframe
,我对此进行了帮助。再加上这个问题,让那些遇到同样问题的人很难找到正确答案。和往常一样,如果你找到了帮助的解决方案,请投票。我提到,加载时会出现脚本错误,不是代码本身,而是谷歌。。。要测试这一点,只需将src替换为
src=https://www.google.com“
。。。如果它加载了代码就可以了。我在另一个网站上测试了我的解决方案,效果很好,不知道为什么没有
body
标签就可以工作。在这里,我没有看到任何关于你提供的源代码…我已经更新了我的代码。你能看看它是否正确吗?你不需要这些;不管怎么说,大部分都是错的,我解释道。将一个新的
WebBrowser
控件放到表单或usercontrol上,就这样。不显示任何内容