如何在 Google Earth 中显示移动的船?

发布于 2024-08-09 04:24:13 字数 322 浏览 1 评论 0原文

我是 KML 格式的新手,尝试弄清楚如何显示一艘船(png),沿着路径(由多条线绘制的简单线)从一个地方移动到另一个地方。

我可以看到如何分别显示地标,甚至带有图标和路径。

当我点击KML文件时我希望看到的是:

  • 船出现在出发点;
  • 路径自行绘制直至到达;
  • 船图标沿着路径从出发到到达以舒适的速度移动(奖励点是我可以设置配给时间/进度,如果我可以单击开始、暂停或倒带,则额外奖励)。

这可能吗?我知道它是用 Google Map 实现的,但你可以用 Javascript 对其进行编程,这让事情变得容易很多。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

只有一腔孤勇 2024-08-16 04:24:13

这是一个老问题,现在有一种更好的方法可以沿着预先确定的线串移动地标(甚至更好的模型)。了解如何使用此功能:

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

示例代码:

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

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>
颜漓半夏 2024-08-16 04:24:13

我能够在静态 KML 中完成这项工作的唯一方法是在开始点和停止点之间进行插值,并为我想要制作动画的每个帧添加地标。所以,从t=0到t=1,在起点画一个地标。从 t=1 到 t=2,在下一个点绘制地标,依此类推。

这将为您提供 Google 地球中的时间播放器栏,您可以倒回或前进动画。然而,这有点烦人,因为您最终会得到地标树中的每个插值点。将地标放在自己的文件夹中可以使它们不碍事,但无法对用户隐藏它们。

查看 http://code.google.com/apis/kml /documentation/time.html#animating
鲸鲨示例或多或少地满足了您对地标的要求。 (标记图标的 URL 已损坏)。可以使用相同的技巧来制作沿轨道的进度动画。

如果您想尝试更困难的事情,可以尝试提供动态 KML。让 Google 地球加载指向您的初始数据的网络链接。然后加载另一个网络链接,该链接会在每次更新时发送地标更新。

这种方法有一些严重的缺点,因为它需要外部程序来驱动 Google 地球,并且不允许用户访问内置的 Google 地球临时播放器栏。它还要求通过网络链接加载所有数据——文件中的 KML 数据无法更新。这意味着您的驱动程序需要充当 http 服务器。此外,在此模型中,很难确切知道 Google 地球何时完成加载和绘制更新。我真的不建议这样做;您可以使用 Google Earth COM API 使其工作,但它始终是一个脆弱的解决方案。

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.

爱冒险 2024-08-16 04:24:13

有一个浏览器插件可以让您将 Google 地球嵌入到浏览器页面中。从那里,您可以使用 JavaScript 为地标设置动画、更改路径等。查看 Google 地球 API 开发人员指南

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.

影子是时光的心 2024-08-16 04:24:13

如果您要在 Google 地球上显示一艘船,3D 模型将是比图像更好的方法,因为用户可以更改视角。

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.

想你的星星会说话 2024-08-16 04:24:13

您可能想查看游览:http://code.google.com/ apis/kml/documentation/touring.html

我见过这样的事情,使用(多个) 标签的组合来移动先前创建的地标代表您的船和 标签来移动视图(我认为)全部在 内。

希望这有帮助。

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.

策马西风 2024-08-16 04:24:13

我假设最初回答时此功能不存在,但您可以使用游览来实现效果。下图显示了以这种方式移动的地标。

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

路径上可以标有一些点,这些点的可见性会因旅行在适当的时间而改变。

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.

心意如水 2024-08-16 04:24:13

我在 Google 网站上有以下示例。希望这有帮助。

(详细信息请参阅:https://sites.google.com /site/canadadennischen888/home/kml/auto-refresh-3d-tracking)

  1. 准备 RestFul 服务从数据库生成 KML 文件
    (示例如 https://sites.google.com/site/canadadennischen888 /home/kml/3d-tracking)

  2. 我的其他代码将生成一个 KMZ 文件,其中包含指向我的 Restful 服务的链接
    (示例如本页所示)

  3. KMZ 文件具有 onInterval

  4. 网页允许用户下载 KMZ 文件,该文件具有链接到我的 Restful 服务的 URL

  5. 当 Google 地球打开 KMZ 文件时,Google 地球将自动刷新以从该 Restful 服务获取新数据

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

谷夏 2024-08-16 04:24:13

只需在 google 上搜索“kml 时间动画”

KML:时间和动画

< a href="http://earth.images.alaska.edu/geog493/kml/animation.html" rel="nofollow noreferrer">KML:动画

使用 KML 进行动画和动态更新

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文