Touring With Google Earth 5

By Kurt Cagle
February 6, 2009 | Comments: 1

Google Earth 5 hit the Internet earlier this week (visions of some cataclysmic asteroid impact come to mind with that statement), debuting everything from a historical mode that lets you see the evolution of terrain over time to a dramatically expanded oceanographic mode that lets you see a whole new world 'under da sea' to the rather stunning release of Google Mars, in which the orbiter maps from the exploratory missions of the last decade are now laid out in stunning detail (and hopelly waking up a whole new level of appreciation for the Red Planet).

Google Earth has, since its inception, been redrawing the map as far as GIS is concerned. While the notion of modeling maps of earth in 3D is nothing new in GIS programs, most of these tended to be stand-alone applications with very specific uses, and also tended to be sufficiently expensive as to not be feasible for the average user.

Google Earth, on the other hand, brought GIS to the masses, making it possible for school kids to not only explore the world in depth in a way that geography teachers could only fantasize about a few years ago but could also make it possible for them to create their own tours to do everything from track the path of Odysseus to seeing the world sink beneath the seas in global warming simulations.

While the new Mars and Oceanographic information layers are fascinating and well worth the effort of exploring, there are a number of deeper layers of functionality that should be of interest to developers of Google Earth applications. One of the first is the opening up of the GPS API so that users could upload their coordinates from GPS enabled devices directly into a Google Earth app. This functionality was available in the commercial version of Google Earth before, but has been migrated to the free version in Google Earth 5.

The GPS upload capability is found in the Tools->GPS menu in GE5, and lets you import both Garmin and Magellan GPS formats, lets you set up links between points automatically and lets you adjust for height. Additionally, you can pull in real time GPS feeds using NMEA and Garmin PVT settings, which is very useful if you're using Google Earth on laptops with GPS receivers.

This functionality is especially intriguing given the other major new technological goody embedded in Google Earth - the ability to create tours. In a tour, the KML acts like a script to drive Google Earth from one state to another under timed control. This not only allows for point to point "hops", but also lets you pop up placemarks (which may include movies) and later release them, lets you change overlays and buildings, and even lets you control the time-line, using the smooth "bounce" mechanism that keeps Google Earth from jerking at endpoints.

Tours have been an oft-requested capability of Google Earth aficionados for some time, for good reason. Google Earth can be a very distracting application, and it is all too easy when following a path to stray from the path, losing sight of the initial objectives of the designer of that path (and frequently losing the path itself). A tour essentially gives control over to Google Earth, making it easier to build narratives.

For instance, suppose that you wanted to showcase how to get from an airport to a hotel for a conference. Using Google's placemarks, you can designate key points along the way, such as critical turns, areas where they may be traffic congestion, as well as notable sites along the way that may be worth exploring at some later point. Once you have the path laid out, you can run the Tour recorder, a pop-up control that will let you record your path, then click on each placemark in turn to jump to that point at the appointed time. This is even enhanced with the capability of adding a voice-over to the presentation (good for quick and dirty recording, though you'll probably want to go back and edit the audio file with a more professional tool later).

Along the way you can cause caption balloons for placemark and regions to pop up, you can toggle 3d buildings on and off, can change the timeline, and can even run other tours within the primary tour, making it much easier to build up complex tours from smaller, more manageable sub-tours - this can be very important, especially when doing live narration, as the interfaces don't allow for more detailed editing. You can record individual clips, but you don't have pause capability (yet).

Once you've finished recording, Google Earth will automatically replay it once so that you can see your efforts, and also allows you to save it as a KML or KMZ (zipped KML) file. If you do a voice recording the Save capability will also create a subfolder called files that includes the voice mp3 file that you created.

In 2007, Google Earth agreed to incorporate the KML 2.2 specification into the Open Geospatial Consortium's Geography Markup Language (GML) specification. This has meant that any new changes that Google wished to make to the specification needed to be done under a separate namespace until such time as the functionality was incorporated into a newer GML effort (this looks like it may very well become a model of XML versioning for a number of other efforts). As a consequence, most of the new KML code is actually published under the namespace "http://www.google.com/kml/ext/2.2" (with the default prefix for this being the somewhat universal gx: for Google extensions).

The results of a simple recording session produced a fairly long KML session (see a snippet in Listing 1).

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"
	xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
	<gx:Tour>
		<name>Guided Tour to the Ferry</name>
		<LookAt>
			<longitude>-123.4092907873684</longitude>
			<latitude>48.68946764143825</latitude>
			<altitude>0</altitude>
			<range>567.6305685937824</range>
			<tilt>33.42415477496115</tilt>
			<heading>-6.719061033810108</heading>
			<altitudeMode>relativeToGround</altitudeMode>
		</LookAt>
		<gx:Playlist>
			<gx:SoundCue>
				<href>files/~GEA8A5.mp3</href>
			</gx:SoundCue>
			<gx:FlyTo>
				<gx:duration>3.70158795703901e-006</gx:duration>
				<gx:flyToMode>smooth</gx:flyToMode>
				<Camera>
					<longitude>-123.32130524435</longitude>
					<latitude>48.47129869648397</latitude>
					<altitude>191.6902006099002</altitude>
					<heading>1.963151127141719</heading>
					<tilt>31.30611525829769</tilt>
					<roll>-1.749305074804934e-014</roll>
					<altitudeMode>absolute</altitudeMode>
				</Camera>
			</gx:FlyTo>
			<gx:Wait>
				<gx:duration>28.71469264948519</gx:duration>
			</gx:Wait>
                        <!-- More FlyTo's and Waits -->
                </gx:Playlist>
          </gx:Tour>
</kml>

Anything in the gx: namespace is new. The gx:Tour term provides a wrapper around the tour and includes any associated metadata, including the initial "face" - the LookAt element that's presented if the tour is checked but not activated. gx:Playlist in turn provides a sequence of actions, which include both place indicators for FlyTo actions (much like Placemarks, but with an additional gx:duration tag) and Wait actions.

FlyTo durations indicate the amount of time necessary to fly from the current position to the indicated one, so setting this value (in seconds) low can result in a rapid jump, while a higher value would provide a far more sedate traversal. You can also control the FlyToMode, which can have a value of smooth or bounce. In smooth mode, if you have a sequence of FlyTo actions, GoogleEarth will interpolate a smoothing curve between these points, so that the velocity doesn't reach zero until the end of the sequence. Bounce mode, on the other hand, will create a smoothing curve that will accelerate from zero at the beginning of a sequence and will decelerate to zero at the end of the sequence, giving a series of Kangaroo hops.

The SoundCue command starts the playing of a given sound file at that point in the playlist. SoundCues can be run in parallel (can overlap). This means that you can set up one SoundCue as a background track, then insert individual narrations at key point (possibly offset by gx:Wait elements in order to set precise timing. This is also useful for segues between tracks, as you can edit the sounds in Audacity or similar sound editors to fade out or in as appropriate, then use SoundCue to more precisely time these. (Currently, Google Earth only supports MP3 and AA formats).

Google Earth currently supports two forms of "pausing" - the gx:Wait command and the gx:TourControl command. The Wait command performs no operation for the indicated period of time (though concurrent commands such as SoundCue or AnimatedUpdate are not affected if they have already been invoked). Wait is consequently useful for pacing of FlyTos, as well as for starting sounds or animations.

The gx:TourControl is a little different. TourControl is, as the name implies, a pause assigned to the control itself, and is exactly as if a user had pressed the pause control. This can be useful for tours that include the opportunity for a little "self-guided" exploration. Once you press the start button again in the tour control, it picks up where it left off.

The final (and perhaps most intriguing) new part of tours is the gx:AnimatedUpdate command. This command acts as a wrapper for the XML Update command, but the action is then invoked at a certain time within a tour.

For instance,


<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2">

<Document>
<name>gx:AnimatedUpdate example</name>
<open>1</open>

<Style>
<IconStyle id="iconstyle">
<scale>1.0</scale>
</IconStyle>
</Style>

<Placemark id="mountainpin1">
<name>New Zealand's Southern Alps
<styleUrl>#style
<Point>
<coordinates>170.144,-43.605,0</coordinates>
</Point>
</Placemark>

<gx:Tour>
<name>Play me!</name>
<gx:Playlist>

<!-- The order and duration of TourPrimitives is important;
in this example, the AnimatedUpdate needs
6.5 seconds to complete. The FlyTo provides 4.1,
and the Wait 2.4, giving the update time to
complete before the Tour ends. AnimatedUpdates
don't hold Tours open, but FlyTos and Waits do.
For more information, refer to:
http://code.google.com/apis/kml/documentation/touring.html#tourtimelines
-->

<gx:AnimatedUpdate>
<gx:duration>6.5</gx:duration>
<Update>
<targetHref></targetHref>
<Change>
<IconStyle targetId="iconstyle">
<scale>10.0</scale>
</IconStyle>
</Change>
</Update>
</gx:AnimatedUpdate>

<gx:FlyTo>
<gx:duration>4.1</gx:duration>
<Camera>
<longitude>170.157</longitude>
<latitude>-43.671</latitude>
<altitude>9700</altitude>
<heading>-6.333</heading>
<tilt>33.5</tilt>
<roll>0</roll>
</Camera>
</gx:FlyTo>

<!-- wait for the AnimatedUpdate to complete -->
<gx:Wait>
<gx:duration>2.4
</gx:Wait>

</gx:Playlist>
</gx:Tour>
</Document>
</kml>



will change the scale of all icons defined within the tour to ten size their normal size. over a period of 6.5 seconds. Note that FlyTos and Waits will play their full duration, but neither sounds nor animated updates will - you have to use them in conjunction with Wait command for them to be extend to the end of their play time if that's beyond the existing FlyTo/Wait times.

Once run, AnimatedUpdates have no effect on the long term state of the GoogleEarth environment. Thus, if you loaded overlays, changed the size of icons or modified text in a balloon, these would revert back to their original values upon completion of the term. (Effectively, AnimatedUpdates push a new state onto the stack until they're completed, then are popped off the stack.)

Tours will very likely become one of the most widely used features within Google Earth. However, in conjunction with the release of the stand-alone application, Google also performed another bit of legerdemain: it released browser plugins for Internet Explorer and Firefox (and will soon presumably work for Chrome). These plugins make it possible to run Google Earth within a web page, as well as to control this instance via JavaScript using the Google Earth API. This capability (as well as support for JavaScript within KML in Balloons and other text regions) should push Google Earth maships into high gear.

More information about KML support for tours and other goodies is available from the Google Earth Developer's Guide. I have to admit I'm looking forward to traversing the Earth in a whole new way.

Kurt Cagle is an Editor for O'Reilly Media. You can catch his O'Reilly blog or subscribe to XMLToday.org, or follow him on Twitter.


You might also be interested in:

1 Comment

i have ever do GPS using mapinfo and use gps to warning a earthquake but it's only my senoir project with google earth 5 is very interesting it' s look like google is go to next step of every one now i have Garmin 3790t it's very good too

News Topics

Recommended for You

Got a Question?