玩用 KML 编写的游览时,是否可以动态控制相机?

发布于 2025-01-07 02:55:19 字数 246 浏览 2 评论 0原文

使用 Google 地球插件 AI,我想通过游览功能,但让用户在播放过程中修改相机控件

是否可以?

Using the Google Earth plugin AI, I want to play a tour authored in KML with the touring capability, but let the user modify the camera controls during the play.

Is it possible?

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

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

发布评论

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

评论(2

情深缘浅 2025-01-14 02:55:20

这取决于您想要允许多少修改。

游览回放旨在配合用户更改视图方向(通过拖动或摄像机控件),但不能更改位置。如果用户停止更改视图的时间足够长,相机将平滑地恢复到游览中该点的默认方向。缩放和平移控件在游览期间消失,但​​如果用户尝试通过其他方法(如键盘)更改摄像机位置,游览通常会暂停。

然而,Earth API 允许您吸收或更改任何这些事件行为,因为您可以添加鼠标和键盘事件的侦听器,并阻止它们照常处理或以完全不同的方式对其进行操作。

如果您还没有尝试过,Google 代码中有一个游览示例您可以在 Playground 中查看基于默认事件响应的不同交互所发生的情况。

最后,如果您想要真正自定义的游览行为(例如,即使游览继续,也允许摄像机进行某些类型的移动远离游览路径),您很可能需要编写自己的摄像机移动代码。掌握这项工作的基础知识并不太困难,但获得这种交互的正确直观感觉却很困难,而且可能依赖于数据集。首先,您可以直接解析 KML,找到游览及其包含的游览图元,然后使用您引用的常规摄像机控件在这些图元之间移动,为任何用户提供的移动添加偏移量。

编辑:问题中引用的 Earth API 游览页面有开始解析 KML 的示例file 通过让插件为您完成此操作。您可以使用它来实现上述建议,即使用 KML DOM 遍历代码查找所有游览基元(而不是在找到游览元素后立即停止)。

这并不总是最有效的方法(插件函数调用有开销,同时浏览器具有内置的 XML 解析功能),但它可能是最直接的开始方法。对于许多旅行来说,这种方法就足够了。

It depends on how much modification you want to allow.

Tour playback is designed to work with the user changing the orientation of the view (via dragging or the camera controls), but not the position. If the user stops changing the view for long enough, the camera will smoothly snap back to the default orientation for that point in the tour. The zoom and panning controls disappear during the tour, but if the user tries to change the camera position via other methods (like the keyboard), the tour will typically be paused.

The Earth API, however, allows you to absorb or change any of those event behaviors, since you can add a listener for mouse and keyboard events and prevent them from processing as usual or act on them in a completely different way.

If you haven't tried it, there's a tour example in the Google Code Playground where you can see what happens with different interactions based on the default event responses.

Finally, if you want really custom tour behavior -- like allowing certain kinds of movement of the camera away from the tour path even as the tour continues -- you will most likely need to write your own camera movement code. Getting the basics of this working isn't too difficult, but getting the right intuitive feel for that kind of interaction is difficult, and probably dataset-dependent. To get started, you can parse the KML directly, find the tour and the tour primitives it contains, and then use the regular camera controls you cited to move between those primitives, adding offsets for any user-supplied movements.

edit: the Earth API tour page cited in the question has an example of getting started with parsing the KML file by getting the plugin to do it for you. You can use this to implement the above suggestion by using the KML DOM walking code to find all the tour primitives (instead of halting as soon as a Tour element is found).

This isn't always the most efficient approach (plugin function calls have overhead, and meanwhile browsers have built-in XML parsing capabilities), but it may be the most straightforward way to start. For many tours, this approach would be perfectly sufficient.

烟沫凡尘 2025-01-14 02:55:20

这是可能的,但很难实施,更难控制好。我已经尝试这样做已经有一段时间了。我自己并没有取得太大的成功,但这里有其他人取得了一些进展的两个例子。

首先,他们使用的基本原理是基于 TICK - 一个简单的例子在这里
http://earth-api-samples.googlecode.com /svn/trunk/examples/event-frameend.html

这两个示例是:
http://maps.myosotissp.com/

http://racemyrace.com/race.php

另外,这里有一个示例,直到最近,我不知道为什么它停止了,但看来你仍然可以阅读正在使用的 JS。它是由创建racemyrace 网站的同一个人制作的
http://www.thekmz.co.uk/GEPlugin/pathtour/v3 /path_tour_v3.htm

如果您碰巧解决了问题,我将不胜感激您创建一个简单的示例页面并共享链接。这可能需要一段时间,所以如果您可以通过个人资料查找我的电子邮件并通知我那就更好了。

祝你好运!

It is possible, but pretty hard to implement and even harder to control well. I have been playing around with trying to do this for quite a while now. I have not had much success myself, but here are two example by others who have made some progress.

Firstly, the underlying principle they are using is based upon the TICK - a simple example of it is here
http://earth-api-samples.googlecode.com/svn/trunk/examples/event-frameend.html

The two example are :
http://maps.myosotissp.com/
and
http://racemyrace.com/race.php

Also, here is an example that used to work up until recently, I am not sure why it has stopped but it appears you can still read the JS being used. It is made by the same person who created the racemyrace website
http://www.thekmz.co.uk/GEPlugin/pathtour/v3/path_tour_v3.htm

If you happen to work something out, I would appreciate you creating a simple example page and sharing the link. It will probably take a while so if you could look up my email via profile and notify me that would be even better.

Good Luck!

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