Search code examples
kmlgoogle-earth

How to display a moving boat in Google Earth?


I am new to the KML format and try to figure out how to display a boat (a png), moving from a place to another along a path (a simple line drawn composed of several lines).

I can see how to display a Placemark, even with an icon, and a Path, separately.

What I would like to see when I click on the KML file is :

  • the boat appearing at the departure point;
  • the path drawing itself until the arrival;
  • the boat icon moving at a comfortable speed (bonus point it I can set a ration time / progress, extra bonus if I can click on start, pause or rewind) from departure to arrival along the path.

Is that even possible ? I know it is with Google Map, but you can program it with Javascript, which eases things a lot.


Solution

  • This is an old question, and there is now a better way to move a placemark (or even better a model) along a pre-determined linestring. Look into using this feature:

    http://code.google.com/apis/kml/documentation/kmlreference.html#gxtrack

    Sample code:

    <?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">
    <Folder>
      <Placemark>
        <gx:Track>
         <when>2010-05-28T02:02:09Z</when>
         <when>2010-05-28T02:02:35Z</when>
         <when>2010-05-28T02:02:44Z</when>
         <when>2010-05-28T02:02:53Z</when>
         <when>2010-05-28T02:02:54Z</when>
         <when>2010-05-28T02:02:55Z</when>
         <when>2010-05-28T02:02:56Z</when>
         <gx:coord>-122.207881 37.371915 156.000000</gx:coord>
         <gx:coord>-122.205712 37.373288 152.000000</gx:coord>
         <gx:coord>-122.204678 37.373939 147.000000</gx:coord>
         <gx:coord>-122.203572 37.374630 142.199997</gx:coord>
         <gx:coord>-122.203451 37.374706 141.800003</gx:coord>
         <gx:coord>-122.203329 37.374780 141.199997</gx:coord>
         <gx:coord>-122.203207 37.374857 140.199997</gx:coord>
       </gx:Track>
     </Placemark>
    </Folder> 
    </kml>