open kml programatically

1,162 views
Skip to first unread message

bbrehm6525

unread,
Oct 19, 2011, 10:36:23 PM10/19/11
to KML Developer Support - Getting Started with KML
This is a beginner question.

I have written a small C++ program to create a KML file. I have
searched in this forum for my question but couldn't find an answer.

How do I get the KML file I just created to open up in Google Earth? I
want to do this with code in my program, not having to open manually
from within GE or dragging the KML onto GE.

I tried calling googleearth.exe with a command line parameter but that
didn't work.

Thanks for any advice...

ErinH

unread,
Oct 20, 2011, 1:41:28 PM10/20/11
to KML Developer Support - Getting Started with KML
Could you post if you get an answer, please? I'm trying to do this
too.
thanks,
Erin

bbrehm6525

unread,
Oct 21, 2011, 12:47:47 AM10/21/11
to KML Developer Support - Getting Started with KML
I have a less than satisfactory solution.

If I launch GE from within my application and pass the file name as a
command line parameter it will load the file. In VC++ 6.0 I do this:

_spawnl(_P_NOWAIT, "C:\\Program Files (x86)\\Google\\Google Earth\
\client\\googleearth.exe", "googleearth.exe", "\"C:\\My Folder\\" +
m_title + ".kml\"", NULL);

If GE is not open, it will open it and load the file into Temporary
Places and fly to the location. If GE is open, it will pop into focus
and load and fly.

But when GE is already open, this code actually launches a second copy
of GE which then thinks for a while and decides there is another copy
of GE open and closes itself and sends the file to the first copy. And
it's slow. When GE is not open, it takes about ten seconds to launch
and show the file. That's okay. When GE is open, it still takes about
eight seconds to display the file. Not really okay. This timing is on
my work workstation which is powerful. At home on my laptop, GE takes
minutes to launch. If opening a file this way also takes almost that
long on my laptop it will be unacceptable. I'll try tonight when I get
home.

Since the second copy of GE must be telling the first copy to open the
file, there must be a way that we could do it too. If anyone knows,
please share with us here. Also, when reopening the same file, GE will
ask if it's okay to reload. If there is a way to tell GE in the
command line or programatically to just do it, please also share with
us.

Thanks...

bbrehm6525

unread,
Oct 23, 2011, 8:41:08 PM10/23/11
to KML Developer Support - Getting Started with KML
I tested on my laptop at home. Although it takes many minutes to open
GE, when I use the above technique to open a KML file it is as fast as
it is on my workstation at work - less than 10 seconds.
Reply all
Reply to author
Forward
0 new messages