My favorites | English | Sign in

Google Earth API

Google Earth API Developer's Guide

Welcome to the developer documentation for the Google Earth API. The Google Earth Plug-in and its JavaScript API let you embed the full power of Google Earth and its 3D rendering capabilities into your web pages. Just like in the Google Maps API, you can draw markers and lines—but in 3D!

See the Google Earth API developer forum if you have have questions about the API after reading this developer guide.

Table of Contents

  1. Audience
  2. Installing the Google Earth Plug-in
  3. Getting Started with the Google Earth API
  4. Troubleshooting
  5. Additional Resources

Audience

This documentation is designed for people familiar with JavaScript programming and object-oriented programming concepts. The Google Earth API is modelled after KML, so you should also consult Google's KML documentation.

Installing the Google Earth Plug-in

Before you can use the API, you must first install the Google Earth Plug-in.

Note: Your users will also need to install the plugin to interact with Google Earth on your web site.

The Google Earth Plug-in is currently available for the following web browsers and operating systems:

  • Microsoft Windows (2000, XP, and Vista)
    • Google Chrome 1.0+
    • Internet Explorer 6.0+
    • Firefox 2.0+
    • Flock 1.0+
  • New! Apple Mac OS X 10.4 and higher (Intel and PowerPC)
    • Safari 3.1+
    • Firefox 3.0+

Although the plugin and API may work correctly on other browsers that support NPAPI with npruntime extensions, these browsers are not officially supported.

To begin using the Google Earth API:

  1. Visit the Hello, Earth sample application, or any other website that uses the Earth API, to install the plugin.
  2. Sign up for a Google Maps API key.
  3. Copy the Hello World snippet from the Basic Topics page to your own website and substitute your API key.

Uninstalling the Google Earth Plug-in

To uninstall the Google Earth Plug-in on Windows, from the Start menu, select Google Earth Plug-in and then Uninstall.

To uninstall the Google Earth Plug-in on Mac, follow the uninstallation steps as listed on the FAQ.

Getting Started the Google Earth API

You can either use the Google Earth API by itself or you can use it together with the Google Maps API. If you already have Google Maps embeded in your web page, you can enhance it by giving your users the option to view the contents in either Google Maps or in the Google Earth Plug-in. By incorporating the Google Earth Plug-in, users will have the option to display the information in 3D, while also viewing terrain, geometry, and many other Google Earth features.

Hello, Earth

The canonical Google Earth API example is Hello, Earth. Take a look at this sample in the Basic Topics section of this Developer's Guide for an idea of what Earth API code looks like.

Example Code

Most of the examples in this documentation show only relevant JavaScript code, not the full HTML file. You can plug the JavaScript code into your own skeleton HTML file, or you can visit the following resources for Earth API samples:

  • Earth API Demo Gallery - Browse the full collection of Earth API demos and samples, including community contributions.
  • AJAX APIs Playground New! - Interact with JavaScript snippets and export or save your resulting HTML and JavaScript code.
  • Basic Samples - Investigate individual API features with these standalone samples containing full HTML.
  • Interactive Sampler - Experiment with a list of predefined JavaScript samples or enter your own JavaScript code and see the changes immediately!

Troubleshooting

If your code doesn't seem to be working, here are some approaches that might help you solve your problems:

  • Make sure your API key is valid.
  • Look for typos. Remember that JavaScript is a case-sensitive language.
  • Use a JavaScript debugger. In Firefox, you can use the JavaScript console, the Venkman Debugger, or the Firebug add-on. In IE, you can use the Microsoft Script Debugger. This series of screencasts demonstrates how to use the various debugging tools.
  • Search the developer forum. If you can't find a post that answers your question, post your question to the group along with a link to a web page that demonstrates the problem.
  • See Additional Resources for more developer resources.

Additional Resources

If you need more information about Google Earth, KML, or Google Maps, refer to the following: