How to display a moving boat in Google Earth?
Asked Answered
S

8

23

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.

Selina answered 28/10, 2009 at 22:39 Comment(8)
what base data do you have? only endpoints of the paths like you wuold have for planning a boats trip, or do you have data from a GPS that you want to display in a "movie like" way?Bara
I have a starting point, an arrival point and some check point along the path.Selina
+1 just for it being a valid boat questionHeadcloth
retagged as boat-programming, just for fun.Selina
And I removed the boat-programming tag because tags aren't for fun.Nobe
Wow, you're the kind of guy to downvote the "best programming cartoon" question, aren't you ?Selina
Sounds like the programming is about to get off-shoredHaven
@e-satis: Yes. I also vote to close such "questions". @simon: You forgot to pause and put on your sunglasses in the middle of that...Nobe
D
12

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>
Dendrology answered 18/2, 2012 at 21:57 Comment(0)
S
11

The only way I've been able to make this work in static KML is to interpolate between the start and stop points and add placemarks for each frame I want to animate. So, from t=0 to t=1, draw a placemark at the start point. From t=1 to t=2, draw a placemark at the next point, etc.

This gives you the temporal player bar in Google Earth and you can rewind or advance the animation. However it is a little annoying because you wind up with every interpolation point in your placemark tree. Putting the placemarks in their own folder keeps them out of the way, but there's no way to hide them from the user.

Take a look at http://code.google.com/apis/kml/documentation/time.html#animating The whale shark example does more or less what you want for the placemark. (The URL for the marker icon is broken). Animating the progress along the track can be done using the same trick.

If you want to try something much more difficult, you can try serving dynamic KML. Have Google Earth load a network link to your initial data. Then load another network link with an that sends an update for your placemark at every time tick.

This approach has some serious disadvantages because it requires an external program to drive Google Earth and it does not give the user access to the built-in Google Earth temporal player bar. It also requires that all the data be loaded over a network link -- KML data from a file cannot be updated. That means your driver program needs to act as a http server. Also, in this model it is very hard to know exactly when Google Earth has finished loading and drawing the update. Really I don't recommend doing this; you can make it work using the Google Earth COM API, but it will always be a fragile solution.

Screenplay answered 4/11, 2009 at 13:44 Comment(1)
Actually, you can hide placemarks from the user, and you can use link with local files (no need to use http, but in that case you can't set expire headers). Nevertheless, I already explorered these solutions. I didn't get fluid and smooth results. I know this is the way to go, but I am really looking for a clean example hereSelina
L
3

There's a browser plug-in that lets you embed Google Earth into a browser page. From there you can use JavaScript to animate your placemark, change your paths, etc. Check out the Google Earth API Developer's Guide.

Laevorotatory answered 5/11, 2009 at 18:39 Comment(0)
T
0

If you are going to display a boat on Google Earth, a 3D model would be a better approach then an image, since the users can change the viewing angle.

Treasury answered 28/10, 2009 at 22:50 Comment(0)
D
0

You might want to look into tours: http://code.google.com/apis/kml/documentation/touring.html

I've seen something like this done using a combination of (a number of) <gx:AnimatedUpdate> tags to move a previously created placemark representing your boat and <gx:FlyTo> tags to move the view (I think) all within a <gx:Playlist>.

Hope this helps.

Duvall answered 6/11, 2009 at 19:37 Comment(0)
E
0

I'm presuming this functionality did not exist when originally answered, but you can achieve the effect using a tour. The following shows a placemark moving in this fashion.

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

<Placemark id="boat">
    <Point>
        <coordinates>0,0</coordinates>
    </Point>
</Placemark>

<gx:Tour>
    <name>Play me!</name>
    <gx:Playlist>
      <gx:FlyTo>
        <gx:duration>5.0</gx:duration>
        <LookAt>
          <longitude>0</longitude>
          <latitude>0</latitude>
          <altitude>0</altitude>
          <heading>-95</heading>
          <tilt>65</tilt>
          <range>250000</range>
          <altitudeMode>relativeToGround</altitudeMode>
        </LookAt>
      </gx:FlyTo>

        <gx:AnimatedUpdate>
            <gx:duration>5.0</gx:duration>
            <Update>
                <targetHref/>
                 <Change>
                     <Placemark targetId="boat">
                         <Point>
                             <coordinates>1,1</coordinates>
                         </Point>
                     </Placemark>
                 </Change>
            </Update>
        </gx:AnimatedUpdate>
        <gx:Wait>
            <gx:duration>6.0</gx:duration>
        </gx:Wait>
    </gx:Playlist>
</gx:Tour>

</Document>

</kml>

The path could be marked with points whose visibility is altered by the tour at the appropriate time.

Effectually answered 6/5, 2011 at 9:46 Comment(0)
H
-1

I have following sample in Google site. Hope this help.

(details inside : https://sites.google.com/site/canadadennischen888/home/kml/auto-refresh-3d-tracking)

  1. prepare a RestFul service to generate KML file from DB (sample as in https://sites.google.com/site/canadadennischen888/home/kml/3d-tracking)

  2. My other code will generate a KMZ file which has a link to my Restful service (sample as in this page)

  3. KMZ file has onInterval

  4. Web page allow user to download KMZ file which has URL that link to my Restful service

  5. When Google Earth open KMZ file, Google Earth will auto refresh to get new data from that Restful service

Hibernal answered 6/10, 2015 at 18:59 Comment(0)
D
-2

Just google for "kml time animation"

KML: Time and Animation

KML: Animation

Animation and Dynamic Updates with KML

Dreeda answered 28/10, 2009 at 22:45 Comment(1)
I know I can use time stamp, I know I can set a period of time to make events append. I don't know how to make it works the way I described it. For now, I can make pins appear and disappear. Not really the expected result.Selina

© 2022 - 2024 — McMap. All rights reserved.