Click here to Skip to main content
13,452,641 members (54,743 online)
Click here to Skip to main content
Add your own
alternative version


50 bookmarked
Posted 19 Aug 2009

Google Earth in your Windows Form

, 19 Aug 2009
Rate this:
Please Sign up or sign in to vote.
Use Google Earth`s complete functionality on your Windows Form


Almost everyone who is reading this article would have used Google Earth. So here I show how you can use it in your Windows application. It provides all the navigation functionalities of Google Earth. 


The basic requirements which should be fulfilled to use this utility are:

  • Google Earth Plug-in should be installed on your system (small one, takes a minute or two). When you will run this application, it will show you the link itself, so you don't need to worry about it.
  • Since this uses Google APIs, you should have an App key from Google (it's quite easy to get one). Get it from here.
  • You should have Visual Studio installed on your system.

Basic Fundamental

We have an HTML page (using JavaScript) which just displays Google Earth on it. So the basic idea is that we will add a browser control to our application and set the URL to our HTML page. 

HTML Page 

The HTML page uses JavaScript and is not made up of a thousand lines of code. All the work is done by Google. We just need to call certain functions so that we could have the work done.

   <script src=""My App key here"> </script>
   <script type="text/javascript">
      var ge;
      google.load("earth", "1");

      function init() {'map3d', initCB, failureCB);

      function initCB(instance) {
         ge = instance;


	 ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
  ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);

      function failureCB(errorCode) {


   <div id="map3d" style="height: 400px; width: 600px;">

Please notice the first script tag. In its key attribute, you need to add your App key which you get from Google. Even I have one, but I don't feel like making it public. 

Creating Windows Form 

  1. Create a Windows Forms application 
  2. To your form, add a browser control as shown below:  


In the forms designer file (Form1.Designer.cs), change the URL property of your browser control to the HTML file. Also change the URI kind to absolute. 

this.webBrowser1.Url = new System.Uri(System.Environment.CurrentDirectory + "\\" +
       "MYFiles\\MyGoogleEarthFile.html", System.UriKind.Absolute);

Set the height of your browser control to 400 and width to 600 because these are the dimensions in which our Google earth will be shown. 


The final step isn't some big piece of code. So just run your application. That's it.

Do post your comments on the article, whatever way you feel about it. Thanks !!!! 


  • 19th August, 2009: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

India India
I'm a ruby developer in LinkedIn these days but used to code in C# some years back for my hobby projects.

You may also be interested in...


Comments and Discussions

QuestionDoes not show anything :S Pin
Member 1102206727-Aug-14 8:32
memberMember 1102206727-Aug-14 8:32 
QuestionGoogle Earth in Windows Form Pin
TobyTwerl25-Jun-14 18:14
memberTobyTwerl25-Jun-14 18:14 
GeneralMy vote of 1 Pin
fraser_chapman30-Nov-13 15:45
memberfraser_chapman30-Nov-13 15:45 
GeneralMy vote of 1 Pin
fraser_chapman30-Nov-13 15:40
memberfraser_chapman30-Nov-13 15:40 
Questiongo to location Pin
ms_vb10-Jul-12 18:48
memberms_vb10-Jul-12 18:48 
GeneralVery good for GE Plugin beginners Pin
Dave1975199529-Jul-11 5:05
memberDave1975199529-Jul-11 5:05 
Questionwhy can form not resize? Pin
xiaohan18-Nov-09 4:22
memberxiaohan18-Nov-09 4:22 
AnswerRe: why can form not resize? Pin
HiteshSharma24-Nov-09 22:56
memberHiteshSharma24-Nov-09 22:56 
GeneralNice Work Pin
Mohit.naughty28-Aug-09 8:02
memberMohit.naughty28-Aug-09 8:02 
Rantplagiarism sucks... Pin
fraser_chapman27-Aug-09 23:28
memberfraser_chapman27-Aug-09 23:28 
GeneralRe: plagiarism sucks... Pin
Dave1975199529-Jul-11 4:36
memberDave1975199529-Jul-11 4:36 
GeneralRe: plagiarism sucks... Pin
HiteshSharma29-Jul-11 9:33
memberHiteshSharma29-Jul-11 9:33 
GeneralRe: plagiarism sucks... Pin
fraser_chapman30-Nov-13 15:39
memberfraser_chapman30-Nov-13 15:39 
QuestionGo to location? Pin
YojoaDon24-Aug-09 8:10
memberYojoaDon24-Aug-09 8:10 
AnswerRe: Go to location? Pin
HiteshSharma24-Aug-09 21:09
memberHiteshSharma24-Aug-09 21:09 
GeneralAbout the API Pin
xliqz19-Aug-09 7:21
memberxliqz19-Aug-09 7:21 
GeneralRe: About the API Pin
HiteshSharma19-Aug-09 21:58
memberHiteshSharma19-Aug-09 21:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02-2016 | 2.8.180318.3 | Last Updated 19 Aug 2009
Article Copyright 2009 by HiteshSharma
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid