The release of Google Earth 5.2 had a lot of new features, so many that we had to write three different blog posts just to cover it all. Well, OK, four with this one. One of the most exciting features from a developer standpoint is the new KML extension, <gx:Track>.
We wanted a better way to represent movement on and above the globe. Time animation works well, but from a KML standpoint it required very bulky files. In order to “move” a <Point>, you created a new <Placemark> for each time segment. Your <Point> didn’t actually move, it merely was replicated at a different place. This made animating your path rather cumbersome. Instead, we wanted a smoother experience, and one that allowed you to truly animate a <Geometry>. So, we created <Track>. To get a real sense of the power of <Track>, check out this video.
As you can see, a <Model> (a <Model> is a <Geometry> in KML) of an airplane moves smoothly along the <Track>. Let’s take a look at some KML:
<Placemark><name>My first track</name><styleUrl>#mytrackstyle</styleUrl><gx:Track><altitudeMode>absolute</altitudeMode><when>2010-04-07T23:30:55Z</when><when>2010-04-07T23:31:13Z</when><when>2010-04-07T23:31:32Z</when><when>2010-04-07T23:31:52Z</when><when>2010-04-07T23:32:11Z</when> ... <gx:coord>-83.671639 1.675732 7.827881000000001</gx:coord><gx:coord>-83.67233299999999 1.675678 4.943848000000001</gx:coord><gx:coord>-83.672904 1.67574 3.982666</gx:coord><gx:coord>-83.67346499999999 1.675781 4.463257</gx:coord><gx:coord>-83.67400600000001 1.675855 3.501953</gx:coord> ...<Model id="model_2"> ... <Link> <href>/Users/mmarks/Documents/track.kmz/files/mymodel.dae</href> </Link></Model></gx:Track></Placemark>
Track is a parallel array. The first <when> element matches the first <gx:coord> element, the second with the second, and so forth. The <when> element identifies the point on the time slider, and the <gx:coord> the matching location. Google Earth draws a line between each position visible in the time slider. Track also supports <gx:angles>, which allows you to define the heading of a model at any point along the way. If not defined in <gx:angles>, Google Earth will change the orientation of the Model based on the direction between the current position and the one previous.
Since you’re only creating one Track element, instead of re-creating a bunch of <LineString> elements for every time segment, your KML files will be much smaller. In fact, the more coordinates you have, the more benefit you’ll see from it.
One more feature that is really compelling is that you can add <gx:SimpleArrayData> elements to <SchemaData>. <gx:SimpleArrayData> allows you to add a matching array of your own data. In the sample posted here heart rate, cadence and power are added to each point, and when Elevation Profile is turned on in Google Earth, it allows you to view that data as well, as you can see below.
Mano Marks, Geo APIs Team
Give us feedback in our Product Forums.