Connecting to Google Earth

Connecting to Google Earth gives the GE SDK it's unique interface to inject KML objects. Data is injected into Google Earth via a NetworkLink consisting of an HTTP server (host application) and client (Google Earth).

Before connecting to Google Earth, the NetworkLink may be configured specifically for the host application. The functions GE_SetNetworkLinkName(), GE_SetNetworkLinkRefreshRate(), GE_SetHTTPIpAddress(), and GE_SetHTTPPort() are optionally called to configure the NetworkLink before connecting to Google Earth. Once these parameters are set, the GE_Connect() function is called to create the connection to Google Earth.

The GE_Connect() function will also start the Google Earth application if it is not running. A result of this is the delay between googleearth.exe starting and the GE SDK establishing the NetworkLink. If the googleearth.exe process does not completely start before the GE SDK attempts to create the NetworkLink, then communication between the host application and Google Earth will not be made. The GE SDK will wait 5 seconds by default between the starting of Google Earth and the NetworkLink creation. Since this delay can vary for different hardware platforms, the GE_SetExeStartDelay() function is available for adjusting this delay.

If the host application is restarting and Google Earth contains a NetworkLink previously created by the host application, the GE SDK will resume the connection and restore all KML objects into the internal object collections (placemarks, linestrings, ground overlays, screen overlays, photo overlays, models, and polygons). The host application may restore its local collections of these objects by using the GetCount() and GetName() functions for each object (i.e. for Placemarks these functions would be GE_GetPlacemarkCount() and GE_GetPlacemarkName()).

The following code snippets below show how to connect to Google Earth under various languages.


// Set NetworkLink Name
GE_SetNetworkLinkName("C++ Example");

// Set NetworkLink HTTP server parameters

// Start Google Earth and create a connection
if (GE_Connect())
  // connection successful
  // failed to connect


// Set NetworkLink Name
GE.SetNetworkLinkName("C# Example");

// Set NetworkLink HTTP server parameters

// Start Google Earth and create a connection
if (GE.Connect())
  // connection successful
  // failed to connect
The C# GE class was used to call the above functions.

Visual Basic

REM Set NetworkLink Name
GE.SetNetworkLinkName("VB Example")

REM Set NetworkLink HTTP server parameters

REM Start Google Earth and create a connection
If GE.Connect Then
  REM connection successful
  REM failed to connect
End If
The VB GE class was used to call the above functions.

<< Back to Code Samples

Generated on Wed Sep 16 23:50:34 2009 for Google Earth SDK by  doxygen 1.6.1