Animating a line in Google Earth using kml

google-earth, kml

Solution

The trick is to update the LineString element (with an id on that) rather than the Placemark.

Here's a working KML example tour that animates a line changing from a relative altitude of 100 to 500m.

<?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>

        <LookAt>
            <longitude>-88.1351880996469</longitude>
            <latitude>17.09943637744042</latitude>
            <altitude>0</altitude>
            <heading>49.91874373078863</heading>
            <tilt>84.43764019949967</tilt>
            <range>1929.311316966288</range>
            <gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
        </LookAt>

        <Placemark>
            <name>Untitled Path man</name>
            <LineString id="path1">
                <tessellate>1</tessellate>
                <altitudeMode>relativeToGround</altitudeMode>
                <coordinates>
            -88,17,100 -88.20270841086835,17.21899813162266,100
                </coordinates>
            </LineString>
        </Placemark>

        <gx:Tour>
            <name>Play me!</name>
            <gx:Playlist>
                <gx:AnimatedUpdate>
                    <gx:duration>5</gx:duration>
                    <Update>
                        <targetHref/> <!-- Left empty to refer to the current file -->
                        <Change>                          
                            <LineString targetId="path1">
                                <coordinates>
                                    -88,17,100 -88.20270841086835,17.21899813162266,500             
                                </coordinates>                          
                            </LineString>
                        </Change>
                    </Update>
                </gx:AnimatedUpdate>

                 <!-- Wait for the animation to complete (see the touring
                 tutorial for an explanation of how AnimatedUpdate's
                 duration isn't enough to guarantee this). -->
                <gx:Wait>
                  <gx:duration>5.0</gx:duration>
                </gx:Wait>
            </gx:Playlist>
        </gx:Tour>
    </Document>
</kml>

For details see https://developers.google.com/kml/documentation/touring#tourtimelines

Problem

I am pretty accomplished at using the `animated update` function of google earth and am using it to move `models` around. What I would really like to do is to be able to animate a `line` (eg up and down) in Google Earth but am finding this tricky. I have the longitude and latitude of the line at the start. For example line coordinates are: -88,17,100 -88.20270841086835,17.21899813162266,100 I then want to `raise` one end of this line up to an altitude of 500 over a period of 5 seconds. I've drawn the line using `LineString`: ``` <Placemark id="path1"> <name>Untitled Path man</name> <LineString> <tessellate>1</tessellate> <coordinates> -88.,17,100 -88.20270841086835,17.21899813162266,100 </coordinates> </LineString> </Placemark> ``` But Im now lost as to how to use `<gx:AnimatedUpdate>` to move one end up from 100 to 500. Im sure its easy - can someone point me in the right direction??

Original source