Thursday, July 15, 2010

Making Tracks: New KML Extensions in Earth 5.2


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, .
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 , you created a new for each time segment. Your 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 . So, we created . To get a real sense of the power of , check out this video.

As you can see, a (a is a in KML) of an airplane moves smoothly along the . Let’s take a look at some KML:
My first track
#mytrackstyle
de>absolute 2010
o-04-07T23:30:55Z
Z 2010-04-07T23:31:3
2010-04-07T23:31:1
32Z
2010-04-07T23:31:52Z
-83.671639 1.675732 7.827881000000001 -83.67233299999999 1.675678 4.94
2010-04-07T23:32:11Z ...
3848000000001
-83.672904 1.67574 3.982666
-83.67346499999999 1.675781 4.463257
track.kmz/files/mymodel.dae
-83.67400600000001 1.675855 3.501953
...
...
/Users/mmarks/Documents
/rack>
mark>
e
Track is a parallel array. The first element matches the first element, the second with the second, and so forth. The element identifies the point on the time slider, and the the matching location. Google Earth draws a line between each position visible in the time slider. Track also supports , which allows you to define the heading of a model at any point along the way. If not defined in , 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 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 elements to . 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.

For more information, check out the session Josh Livni and I did at Google I/O, and the KML reference for and .
Mano Marks, Geo APIs Team

No comments:

Post a Comment