Go Back  Xtreme Visual Basic Talk > General Discussion > Tech Discussions > How to control Google Earth with VB.NET


Reply
 
Thread Tools Display Modes
  #1  
Old 04-30-2008, 12:11 PM
gayouj's Avatar
gayouj gayouj is offline
Junior Contributor

* Expert *
 
Join Date: Jan 2006
Location: California
Posts: 317
Default How to control Google Earth with VB.NET


Since I've gotten a few posts requesting the code for VB.NET, I've upped the priority on getting that posted to this forum.

There are two projects in the attached zip file:

The GoogleEarth project is a class library assembly that you can include as a reference in your application projects to access all the functionality necessary for automating Google Earth.

The GETest project is a demonstration on how the GoogleEarth assembly is used.

Enjoy.
Attached Files
File Type: zip Gearth.zip (257.8 KB, 2629 views)
__________________
http://www.joshuagayou.com
Reply With Quote
  #2  
Old 04-30-2008, 01:05 PM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

I dont need it now, but I could see me doing something with this at a later date. Many thanks.
Reply With Quote
  #3  
Old 04-30-2008, 01:32 PM
gayouj's Avatar
gayouj gayouj is offline
Junior Contributor

* Expert *
 
Join Date: Jan 2006
Location: California
Posts: 317
Default

Glad to hear that. Best regards!
__________________
http://www.joshuagayou.com
Reply With Quote
  #4  
Old 05-01-2008, 07:23 AM
imarshad imarshad is offline
Newcomer
 
Join Date: Dec 2003
Posts: 11
Default

Thanks for sharing the VB.NET code.... I will test it tomorrow and if it works like the VB6 code then you have saved me days of research and coding and also pulling out my hairs...

Last edited by imarshad; 05-01-2008 at 07:31 AM.
Reply With Quote
  #5  
Old 05-01-2008, 09:15 AM
gayouj's Avatar
gayouj gayouj is offline
Junior Contributor

* Expert *
 
Join Date: Jan 2006
Location: California
Posts: 317
Default

It works.

I've seen only one problem and I'm not sure if there's any way I can fix it in the assembly. In some instances, the code will fail to control GE (GE won't even launch). As far as I can tell, it has to do with installation order but I've never had a chance to really play around and figure out how to reproduce the error reliably.

The easiest way to fix is to just re-install Google Earth (remove it from your system first using the Add/Remove Programs option in the Control Panel). After you re-install it you should have no problems at all (if you ever have any to begin with).

__________________
http://www.joshuagayou.com
Reply With Quote
  #6  
Old 05-01-2008, 10:50 PM
imarshad imarshad is offline
Newcomer
 
Join Date: Dec 2003
Posts: 11
Default

Thanks gayouj,
Yes it works exactly the same way the VB6 one worked.... Do you have any license requirement if I use it in my application or can I freely use it?
Oops I found it.... It is GNU license....

Last edited by imarshad; 05-01-2008 at 11:10 PM.
Reply With Quote
  #7  
Old 05-05-2008, 09:19 AM
gayouj's Avatar
gayouj gayouj is offline
Junior Contributor

* Expert *
 
Join Date: Jan 2006
Location: California
Posts: 317
Default

__________________
http://www.joshuagayou.com
Reply With Quote
  #8  
Old 05-06-2008, 08:48 AM
swdev swdev is offline
Newcomer
 
Join Date: Mar 2008
Posts: 7
Smile This should save my life

I've found a lot code using VB 6 to control GE, but what I need is VB.NET

Thanks for sharing the code,,,

Reply With Quote
  #9  
Old 05-06-2008, 09:09 AM
swdev swdev is offline
Newcomer
 
Join Date: Mar 2008
Posts: 7
Default

I see you answer my question, thank you very much.
But, can we embed GE directly on our VB form?
That is, with our embedded GE in our own VB form, we can control it, add placemark and other

I think it's like Google Earth client it self, the difference is we can add our own application feature inside it.

Is there any simple solution as simple as dragging a component from our VB.NET Toolbox?
Reply With Quote
  #10  
Old 05-06-2008, 09:38 AM
gayouj's Avatar
gayouj gayouj is offline
Junior Contributor

* Expert *
 
Join Date: Jan 2006
Location: California
Posts: 317
Default

There is this method in the API:

iApplicationGE::GerRenderHwnd

http://earth.google.com/comapi/inter...473e6b7826047a

So you could use this to pull the rendered image into your application or to draw graphics on top of the Google Earth application.

Some guy figured out how to do it in C#:

http://groups.google.com/group/kml-s...d0a53459fca522

I don't know if this still requires you to run GE in the background or not. I just took a quick glance at the code to see if it looked like the guy was trying to solve the same problem you are.

Good luck.
__________________
http://www.joshuagayou.com
Reply With Quote
  #11  
Old 05-06-2008, 10:51 PM
imarshad imarshad is offline
Newcomer
 
Join Date: Dec 2003
Posts: 11
Default

There is one big difference with the two versions... Vb6 application loads Google Earth very quickly.... i.e as soon as you click the Start Google Earth button Google Earth starts to load while in VB.NET version it takes about 15-20 seconds before the Google Earth GUI starts loading.... Is this something you have also encountered?
Reply With Quote
  #12  
Old 05-06-2008, 11:08 PM
gayouj's Avatar
gayouj gayouj is offline
Junior Contributor

* Expert *
 
Join Date: Jan 2006
Location: California
Posts: 317
Default

I've noticed some lengthy start up times but never compared VB6 version performance against .NET. I'll check it out tomorrow when I get in to the office.

Thanks for the tip off.
__________________
http://www.joshuagayou.com
Reply With Quote
  #13  
Old 05-06-2008, 11:12 PM
imarshad imarshad is offline
Newcomer
 
Join Date: Dec 2003
Posts: 11
Default

After inserting some breakpoints I have found that the line that stops loading Google Earth for 20 seconds is the following check. How to overcome this?

If (TempFile.Open(m_AppName)) Then
If (InStr(TempFile.ToString, "GetCamera") = 0) Then
RaiseEvent Err("Google Earth version does not support Camera interface.")
Return False
End If
Else
RaiseEvent Err("Could not open Google Earth EXE.")
Return False
End If
Reply With Quote
  #14  
Old 05-06-2008, 11:30 PM
imarshad imarshad is offline
Newcomer
 
Join Date: Dec 2003
Posts: 11
Default

To be precise the line TempFile.ToString is taking all the time.
Reply With Quote
  #15  
Old 05-06-2008, 11:36 PM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

Surely there is a better way to check the version??

While its nice to ask it what features it supports... reading a file, converting it to string, and the doing a string search.. seems very wrong in so many ways.
Reply With Quote
  #16  
Old 05-07-2008, 09:09 AM
gayouj's Avatar
gayouj gayouj is offline
Junior Contributor

* Expert *
 
Join Date: Jan 2006
Location: California
Posts: 317
Default

That was actually code that I lifted from another guy's project. It's a bummer because the Google Earth API didn't support the Camera object up until a certain version. The API doesn't have a method to determine its version (as far as I've seen so far - they may have done a new release) so this really seems to be the only way to check compatability before launching the app.
__________________
http://www.joshuagayou.com
Reply With Quote
  #17  
Old 05-08-2008, 09:59 PM
swdev swdev is offline
Newcomer
 
Join Date: Mar 2008
Posts: 7
Default

I found this that suffice my requirement : http://www.googleearthairlines.com/vb.rar

But haven't able to compile it
ASAP

thx
Reply With Quote
  #18  
Old 05-21-2008, 06:26 AM
imarshad imarshad is offline
Newcomer
 
Join Date: Dec 2003
Posts: 11
Default

gayouj,
I have adopted most of your code to suit my needs....I need your help in the following....

1) How can I display a Label with the Icon? i.e where you display the icon of the airplane I also want some text overlayed like say "A380" or any other text....
How to achieve this?
Reply With Quote
  #19  
Old 05-21-2008, 07:08 AM
gayouj's Avatar
gayouj gayouj is offline
Junior Contributor

* Expert *
 
Join Date: Jan 2006
Location: California
Posts: 317
Default

Quote:
Originally Posted by imarshad View Post
gayouj,
I have adopted most of your code to suit my needs....I need your help in the following....

1) How can I display a Label with the Icon? i.e where you display the icon of the airplane I also want some text overlayed like say "A380" or any other text....
How to achieve this?
In the UpdateKmlFile and UpdateKmlString methods of GEAircraft, modify the following Placemark data:

Code:
<name>A380</name>
This will cause a simple label to appear next to your marker.

Code:
<description>A380</description>
will create one of those description balloon thingies.
__________________
http://www.joshuagayou.com
Reply With Quote
  #20  
Old 05-21-2008, 11:08 PM
imarshad imarshad is offline
Newcomer
 
Join Date: Dec 2003
Posts: 11
Wink

Thanks.... I never knew that it was that easy.....I was thinking on the lines of creating a new kml file for labels......

Last edited by imarshad; 05-21-2008 at 11:33 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->