2012-03-24 27 views
-1

我真的很想找一个简单的方法来建立使用GEplugin的VB.NET应用程序。所以我发现这个项目似乎做了我需要的肮脏的工作:http://code.google.com/p/winforms-geplugin-control-library/使用谷歌地球插件从VB.NET通过FC.GEPluginCtrls

那么,所有的代码发布在那里围绕C#工作,但我需要在VB.NET上。所以,我已经试过这样:

  1. 创建从VB.NET 2010 Express中的一个新的32位解决方案(我只是简单地添加

    <PlatformTarget>x86</PlatformTarget > 
    

    的.vbproj文件中)

  2. 添加参考FC.GEPluginCtrls.dll

  3. 在窗体上插入一个GeWebBrowser控件

  4. 在代码的顶部,添加

    Imports FC.GEPluginCtrls 
    

    然后,在窗体Load事件,把这个代码:

    InitializeComponent() 
    
        GeWebBrowser1.LoadEmbeddedPlugin() 
    
        Do 
        Loop Until GeWebBrowser1.PluginIsReady = False 
    
        GeWebBrowser1.CreateInstance(ImageryBase.Earth) 
    

    ,我认为,将相当于 http://code.google.com/p/winforms-geplugin-control-library/wiki/CreateInstance

因此,该项目编译并没有得到错误,但GeWebBrowser控件保持为空。

回答

0

我其实写了你正在使用的库。您不在侦听PluginReady事件。 http://code.google.com/p/winforms-geplugin-control-library/wiki/PluginReady

要使用VB使用它简单地将基本实施例转换为VB - http://code.google.com/p/winforms-geplugin-control-library/wiki/ExampleForm

另外,环路轮询PluginIsReady是完全不必要的,因为PluginReady事件是异步的。

为了显示地球,你需要的是以下几点。

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     GeWebBrowser1.LoadEmbeddedPlugin() 
End Sub 

要在初始化时使用插件,请使用PluginReady事件。就像是。

Option Strict Off 
Public Class Form1 
    Private Dim _ge as Object = Nothing 
Private Sub GeWebBrowser1_PluginReady(ByVal sender As System.Object, ByVal e As FC.GEPluginCtrls.GEEventArgs) Handles GeWebBrowser1.PluginReady 
     _ge = e.ApiObject ' reference to the Google Earth Plugin object 
     MessageBox.Show(_ge.getApiVersion()) ' _ge is the plugin -use it just as in the javascript api... 
End Sub 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     GeWebBrowser1.LoadEmbeddedPlugin() ' load the plugin 
End Sub 
End Class 
+0

感谢您的回复。但是你的代码与我的代码相同,至少关于组件的初始化。但是,在我的系统中,插件区域保持空白并且没有地球内部。听PluginReady事件不成问题,因为插件已准备就绪,但屏幕上没有任何内容出现。无论如何,我发现了一个棘手的解决方案,将插件嵌入到HTML页面中,并使用InvokeScript方法在其上发送命令。它总比没有好.... – user1290276 2012-04-10 15:40:59

+0

“听PluginReady事件不是问题。”是的,它是 - 我写了你正在使用的库。该库首先使用嵌入式HTML页面和InvokeScript ... – Fraser 2012-04-10 15:57:40