kml route animation

1,420 views
Skip to first unread message

toozie21

unread,
Aug 6, 2008, 12:31:17 PM8/6/08
to KML Developer Support - Advanced Support for KML
Sorry if this has been asked previously, but I couldn't find it
anywhere. I have an animation I would like to display using GPS
coordinates. I currently have a route displayed, and as the animation
moves along, waypoints are added (and old ones removed) from the
screen along the path of the route.

What I am interested in, is if there was a way to not have the whole
route already displayed, but have it be drawn in real time (at the
beginning there is not route, in the middle, you can see where I have
been, but not where I am going, at the end you can see my whole
course).

I have to think that this would be pretty easy, but I cannot find info
anywhere on how to do this.

Any thoughts?
Thanks,
~J

Roman N

unread,
Aug 7, 2008, 6:20:25 PM8/7/08
to KML Developer Support - Advanced Support for KML
J,

The following page has some details about animation in KML:
http://code.google.com/apis/kml/documentation/time.html. Scroll down
to the whale-tracking sample for a sample.

You could accomplish your specific scenario by breaking up the route
into individual LineString placemarks representing one segment (or
step) of the animation. Each segment placemark would contain a
TimeSpan element, each with an <end> equal to the total route's end
time. Each segment's <begin> would be set to the time at which it
should appear... i.e. your first segment <begin> would be the starting
time of the entire route.

Please take a look at the previously mentioned link to get started,
and let us know if you have any questions.

- Roman

toozie21

unread,
Aug 7, 2008, 9:39:19 PM8/7/08
to KML Developer Support - Advanced Support for KML
Hi Roman, thank you so much for the response! I actually had been
using the whale-shark example as my template, but I am having issues.
I had been using .gpx files in the past and want to migrate to the
better .kml files, but I cannot seem to get routes to work right
period (let alone do the route animations like I asked you about). I
took the whale-shark example and modded it with three of my own fixes/
times. When I look at it on GoogleEarth, I see the route showing up
VERY briefly as google zooms into my location, but it is never draws
the route out at the location. Below is the mocked up file, do you
see the error of my ways??

Thanks so much!
~Jason


<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name>Testing Path</name>
<open>1</open>
<description><![CDATA[blah blah blah</p>]]></description>
<LookAt>
<longitude>-76.883815</longitude>
<latitude>39.106663</latitude>
<altitude>0</altitude>
<range>10000</range>
<tilt>0</tilt>
<heading>-0.3840786059394472</heading>
</LookAt>
<Style id="seeadler-dot-icon">
<IconStyle>
<Icon>
<href>http://www.seeadlerpost.com/images/KML/dot.png</href>
</Icon>
</IconStyle>
</Style>
<Folder>
<name>Testing, testing, testing</name>
<open>1</open>
<description>This is only a test</description>
<LookAt>
<longitude>-76.883815</longitude>
<latitude>39.106663</latitude>
<altitude>0</altitude>
<range>10000</range>
<tilt>0</tilt>
<heading>-3.57125742335521</heading>
</LookAt>
<Style>
<ListStyle>
<listItemType>checkHideChildren</listItemType>
<bgColor>00ffffff</bgColor>
<maxSnippetLines>2</maxSnippetLines>
</ListStyle>
</Style>
<Placemark>
<TimeStamp><when>2005-08-22T07:36:00Z</when>
</TimeStamp>
<styleUrl>#seeadler-dot-icon</styleUrl>
<Point>
<coordinates>-76.88934999999999,39.099989,0</coordinates>
</Point>
</Placemark>
<Placemark>
<TimeStamp><when>2005-08-22T07:36:20Z</when>
</TimeStamp>
<styleUrl>#seeadler-dot-icon</styleUrl>
<Point>
<coordinates>-76.883815,39.106663,0</coordinates>
</Point>
</Placemark>
<Placemark>
<TimeStamp><when>2005-08-22T10:36:40Z</when>
</TimeStamp>
<styleUrl>#seeadler-dot-icon</styleUrl>
<Point>
<coordinates>-76.877483,39.111487,0</coordinates>
</Point>
</Placemark>
</Folder>
<Placemark>
<name>The Path</name>
<Style>
<LineStyle>
<color>ff0000ff</color>
<width>2</width>
</LineStyle>
</Style>
<LineString>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<coordinates>
-76.88934999999999,39.099989,0 -76.883815,39.106663,0
-76.877483,39.111487,0 </coordinates>
</LineString>
</Placemark>
</Document>
</kml>

toozie21

unread,
Aug 8, 2008, 8:40:34 AM8/8/08
to KML Developer Support - Advanced Support for KML
OK, I think I have all my problems solved. I was able to get the
route to appear AFTER I unchecked the "Primary Database" box under the
layer options on the left (any idea why I needed to do that?). Then,
I was able to use your advice to animate the route in real time. I
used the same code as my previous post, but the routing at the bottom
has been changed to:

<Placemark>
<name>The Path</name>
<TimeSpan>
<begin>2005-08-22T07:36:20Z</begin>
<end>2005-08-22T07:36:41Z</end>
</TimeSpan>
<Style>
<LineStyle>
<color>ff0000ff</color>
<width>2</width>
</LineStyle>
</Style>
<LineString>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<coordinates>
-76.889350,39.099989,0
-76.883815,39.106663,0
</coordinates>
</LineString>
</Placemark>

<Placemark>
<name>The Path</name>
<TimeSpan>
<begin>2005-08-22T07:36:40Z</begin>
<end>2005-08-22T07:36:41Z</end>
</TimeSpan>
<Style>
<LineStyle>
<color>ff0000ff</color>
<width>2</width>
</LineStyle>
</Style>
<LineString>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<coordinates>
-76.883815,39.106663,0
-76.877483,39.111487,0
</coordinates>
</LineString>
</Placemark>



Thank you so much for your help Roman!
~J
> > > ~J- Hide quoted text -
>
> - Show quoted text -

Roman N

unread,
Aug 8, 2008, 4:17:47 PM8/8/08
to KML Developer Support - Advanced Support for KML
J,

The terrain height (which you turned off by unchecking Primary
Database) may have been obscuring your features. Try changing your
<altitudeMode> elements to "relativeToGround" instead of "absolute".
The "absolute" altitude mode causes the altitude value in the
LineString coordinates to be interpreted as meters above sea level.

- Roman

toozie21

unread,
Aug 8, 2008, 9:03:18 PM8/8/08
to KML Developer Support - Advanced Support for KML
Eureka! You the man Roman. Fixing the altitudeMode did the trick
perfectly! Take the rest of the weekend off, you deserve it!

Thanks again.
~J

hdsebalj

unread,
Aug 18, 2008, 6:16:17 PM8/18/08
to KML Developer Support - Advanced Support for KML
This is an amplifying question to the posts already showing here.
I'm trying to make an animation run in REAL time - i.e. one second of
data in the real world is equal to one second of time in the
animation. I've tried a few things, using the <TimeSpan> element and
the <TimeStamp> element, slowing the animation speed to the lowest
setting possible, all to no avail.
Here's a sample of my latest try, using the suggestion by Roman, and
implemented by Jason, but the animation simply runs too quickly to be
of use:
<Placemark>
<name>A2</name><!-- 0.0 km from A2 --><Style>
<IconStyle>
<Icon><href>A_North.png</href></Icon>
</IconStyle>
<BalloonStyle>
<text>$[description]</text>
</BalloonStyle>
</Style>
<description><![CDATA[<br>as of 18/8/2008 14:01:02PM (PST)<br>]]>
</description>
<Point><coordinates>-120.808854, 35.741133,300</coordinates></Point>
<TimeSpan><begin>2008-08-18T22:01:02Z</
begin><end>2008-08-18T22:02:10Z</end></TimeSpan>
</Placemark>
<Placemark>
<name>A2-1</name><!-- 0.1 km from A2 --><Style>
<IconStyle>
<Icon><href>A_North.png</href></Icon>
</IconStyle>
<BalloonStyle>
<text>$[description]</text>
</BalloonStyle>
</Style>
<description><![CDATA[<br>as of 18/8/2008 14:01:04PM (PST)<br>]]>
</description>
<Point><coordinates>-120.808938,35.742056,300</coordinates></Point>
<TimeSpan><begin>2008-08-18T22:01:04Z</
begin><end>2008-08-18T22:02:10Z</end></TimeSpan>
</Placemark>

Does anyone know of a way to clamp the animation speed to real time?

Cheers,

Derek

On Aug 8, 5:40 am, toozie21 wrote:
> > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages