Thursday, February 17, 2011

Include Google Earth

I want to show in this post, how to include Google Earth in a C# application. As for many programs, there is a library provided by Google for that purpose, the Google Earth API.
But for the simple basics used here, we don't even need this API, because Google provides an online plugin, which can be viewed in the browser.
This plugin is available on the URL http://earth-api-samples.googlecode.com/svn/trunk/demos/desktop-embedded/pluginhost.html, we just have to open this page with a Webbrowser control on the form and immediately get the globe known of Google Earth.
A little downer is, that the end users have to install the plugin, luckily though a message with a download link is displayed in the Webbrowser, if it is missing.
The following code calls the plugin:

private void Form1_Load(object sender, EventArgs e)
{
    webBrowser1.Navigate(@"http://earth-api-samples.googlecode.com/svn/trunk/demos/desktop-embedded/pluginhost.html");
}

An exemplary application could look as follows:

No comments:

Post a Comment