Advanced Google Earth Tours – Part 2

Sat, Apr 17, 2010

Google Earth, Spatial

Advanced Google Earth Tours – Part 2

In Part 1, we went through how to create your placemarks, and how to record your Google Earth tour. In this second part, we’ll dive into editing the KML file directly. KML is a type of XML, so if you’ve never worked with this before, you will want to go through a tutorial, or read The KML Handbook.

In this article, you will learn about some of the important tags that make up a KML document, and how to add in ScreenOverlays, audio files, and videos to your tour. I’ll also go over some best practices for working with KML files and Google Earth.

Organizing your audio, image, and video files

Be consistent with the naming of your mp3 audio files. I simply named mine “pollution 1.mp3″, “pollution 2.mp3″, etc. and placed them in a folder named “files”, but you may choose something more descriptive like “narrations”. Your folder structure should look something like:

  • pollution.kml (the file containing all the placemarks and tour data)
  • [files]
    • pollution 1.mp3
    • pollution 2.mp3
    • etc

That’s it. I’ve stored any photos or videos on the webserver; I wasn’t able to bundle these with the KML file. Initially I had stored the MP3 files separate from the KML, and just referenced their URL (ie: 1.mp3) but it turns out that Macintosh computers were unable to play these files if they were just referenced by URL. Audio files need to be bundled with the KML file if you want them to play on Mac.

If you don’t have your own webserver, you can just as easily store you images on a site such as imgur or flickr (note: I haven’t used these sites for storing images for Google Earth tours. I do not know if there are hotlinking restrictions)

Working with KML in a sane way

Your KML file contains all of the placemarks you defined in Part 1, as well as the Google Earth tour data. It’s all written in XML, so if you’ve never worked with this, it can be a bit intimidating. I will assume you have a basic understanding of XML tags, if not, here is a tutorial to get you started.

We’ll be using a text editor to modify the KML file. I used Aptana Studio for this — nothing fancy, and it’s free.

Now, the key to creating quality work is quick feedback. When we first started making these tours, the only way we could see the changes we made was to remove the KML from Google Earth, and then load it back up again. This really adds up when you’re making a lot of changes, so the the first thing I did was to find a simple way of reloading the file: the Revert feature. Once you’ve made changes to your KML file, switch over to Google Earth, right click your file, and click Revert. It will say “Do you want to reload…” click Yes. Doing this will reload the file, and any changes you’ve made will now be visible. This is the quickest way to load your changes into Google Earth.

Another tip for creating quality work is continual improvement. This is where a version control system like SVN or git comes in handy. These tools help you keep track of all the changes you make along the way, and allow you to roll back to a previous revision if you make a big mistake editing the KML.

Learn more about git with Pragmatic Version Control Using Git — I’ve read this, and recommend it.

Editing the KML file

You’ll see a bunch of different KML tags in the file. For a full description of what these mean, check out “Touring in KML“. What follows below is a brief description of some of these tags:


Below is the markup for a placemark. All of this code was generated by Google Earth when we defined these placemarks in Part 1… everything except the contents of the <description> tag. Inside this tag, you can put any HTML you want, as long as it is enclosed in the <![CDATA[  any kind of html in here ]]> tag. Below, we’ve added the code for a flash movie, and a description. Apologies for some of the text being cut off — for the full source download, there are links at the bottom of the page.

Google Earth will set the id of each placemark, but you can name this anything you want — in fact it’ll help you later on to name it something descriptive.

<Placemark id="alang">
  <name>Alang Shipbreaking Yards</name>
      <object data="" type="application/x-shockwave-flash" width="460" height="311">
        <param name="allowFullScreen" value="true">
        <param name="allowScriptAccess" value="always">
        <param name="autoPlay" value="true">
        <param name="bgcolor" value="#000000">
        <param name="flashvars" value="state=embed&amp;clipId=1443535498">
        <param name="menu" value="true">
        <param name="RSI" value="cbc-production">
        <param name="salign" value="tl">
        <param name="scale" value="noscale">
        <a href="" rel="video">
          <img alt="Environmentalist and scientist Dr. David Suzuki shares his thoughts on how poorly people have treated the ocean." src="" width="460" height="256" />
        Environmentalist and scientist Dr. David Suzuki shares his thoughts on how poorly people have treated the ocean. From taking too much out, as population growth and advances in technology have led to overfishing, to putting too much in, as human garbage is filling the ocean.


In part 1, you made a folder called Overlays. You should see it in your KML file now, and this is where you should put your ScreenOverlays. Have a look below at an example of the Overlays folder with one ScreenOverlay within.

  • ScreenOverlay id – just a descriptive identifier for this overlay.
  • color – 00ffffff – the important part is the 00 at the beginning. This defines how transparent the image should be (00 is fully transparent, ff is opaque). We want our images to start out transparent, and slowly fade in (because it looks cool)
  • Icon href - the URL to the image.
  • overlayXY, screenXY – notice the units are set to fraction, and the values are 0.5. This places the image in the exact middle of the screen.
  • size – the width and height of the image.
  <ScreenOverlay id="01-sea-lion">
    <name>Sea Lions</name>
    <overlayXY x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
    <screenXY x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
    <rotationXY x="0" y="0" xunits="fraction" yunits="fraction"/>
    <size x="400" y="300" xunits="pixels" yunits="pixels"/>


A FlyTo directs the camera where to go during the tour. You’ll see tens or hundreds of these tags throughout the file, depending on how long your tour is.



This tag tells the camera to wait at the current point for a number of seconds. Usually you’re waiting for a narration to finish, or waiting while an image is displayed on the screen.


Putting in your own tags

My first scan through the KML, I will put in comments to help me remember where the camera is located at that point in the tour. Go through the code and look for <gx:Wait> tags with larger values (ie: 2 seconds and up). Remember that when you recorded the tour, you waited at each placemark for a little while – by finding this <gx:Wait> tag, you’ve located the point at which the camera arrives at the first placemark. There may also be a <gx:AnimatedUpdate> here, which usually means that a placemark balloon is being displayed.

<!-- Depart-for: "name of destination" -->
<!-- Arrive-at: "name of destination" -->


To begin playing an audio file, use the code below. I like to add a comment describing the file.

<!-- Narrate: pollution 3 - "This Northern right whale, already an endangered species, is trapped in a floating " -->
  <href>files/pollution 3.mp3</href>

Showing a placemark description balloon

In the code below, we show the alang placemark’s description, pause the tour and wait for the user to press play, then hide the description. The pause gives the user time to read the description, or watch the video. Note that there is a one second <gx:Wait> at the end to give the balloon a bit of time to fully close before moving on with the tour.

<!-- Show balloon, pause, then hide balloon -->
<!-- Show: Balloon -->
    <Change><Placemark targetId="alang"><gx:balloonVisibility>1</gx:balloonVisibility></Placemark></Change>

<!-- Pause -->

<!-- Hide: Balloon -->
    <Change><Placemark targetId="alang"><gx:balloonVisibility>0</gx:balloonVisibility></Placemark></Change>

Showing a screen overlay

Here we are fading in the 09-leatherback overlay, waiting for 20 seconds, and then fading it out. Read my comments within my code for a description of what each tag is doing.

<!-- Show: Overlay: 09-leatherback  -->
<gx:AnimatedUpdate> <!-- make sure overlay is hidden -->
    <Change><ScreenOverlay targetId="09-leatherback"><visibility>1</visibility><color>00ffffff</color></ScreenOverlay></Change>
<gx:AnimatedUpdate> <!-- fade the overlay into visibility over 2 seconds -->
    <Change><ScreenOverlay targetId="09-leatherback"><visibility>1</visibility><color>ffffffff</color></ScreenOverlay></Change>
<gx:Wait><gx:duration>20</gx:duration></gx:Wait> <!-- keep the overlay on the screen for 20 seconds -->
<gx:AnimatedUpdate> <!-- fade the overlay out over 2 seconds -->
    <Change><ScreenOverlay targetId="07-garbage"><visibility>1</visibility><color>00ffffff</color></ScreenOverlay></Change>

Testing as you go

As you make changes, you’ll want to test that everything looks fine in Google Earth — use the Revert feature (described earlier) to load your changes. Getting your wait durations to be just right can be time consuming, so make sure you give these plenty of time: it’s simpler to trim it down than to figure out how much you need to lengthen a wait.

Packing it up

Once we’re satisfied with our tour, it’s time to pack it up as a KMZ file. Now, this is just a ZIP file that contains your KML and audio files… nothing fancy. To make a KMZ file:

  1. Right click in your project’s folder (ie: where your KML file is located)
  2. Click New | Compressed (zipped) Folder
  3. A ZIP file will be created.
  4. Name this file the same as your KML file (eg:
  5. Drag your KML file and your files folder (containing your audio files) into this ZIP file.
  6. Rename the ZIP file so it ends in .kmz (eg: change to pollution.kmz)

Now you’ve got a KMZ file you can distribute to anyone, and they’ll be able to see your tour!


, , , , ,

3 Responses to “Advanced Google Earth Tours – Part 2”

  1. Evia Greif Says:

    i loved it, it was easy to follow.


  1. Advanced Google Earth Tours – Part 1 | Soupbo - April 17, 2010

    [...] part 2 of this series, we look at how [...]

  2. Tweets that mention Advanced Google Earth Tours – Part 2 | Soupbo -- - April 18, 2010

    [...] This post was mentioned on Twitter by vergilk and Vergil Kanne, Robin Hillman. Robin Hillman said: Just posted 'Advanced Google Earth Tours' – Part 1, Part 2 #googleearth #oneocean [...]

Leave a Reply

Switch to our mobile site