3D 建筑物上的 Google 地球插件点击事件

发布于 2024-11-29 10:28:08 字数 458 浏览 0 评论 0原文

我一直在四处寻找,但还没有找到这个问题的答案。是否可以使用 Google Earth 插件的 JavaScript 将点击事件添加到 3D 建筑层或自定义 3D 模型。

我的最终目标是能够让用户选择 3D 建筑物,并显示一个包含该建筑物详细信息的信息气泡。这不是 Google 显示的包含 3D 模型信息的默认气泡。

理想情况下,人们能够使用 3D 建筑层,而不是手动加载模型,尽管我对此不太抱有希望,因此通过手动上传的 3D 模型来实现这一点是一种可能。

我正在使用 google 地图 api V3 和 Google Earth 实用程序库来激活插件。

预先感谢您的任何答复。

I have been looking around and haven't found an answer to this yet. Is it possible to add click events to either the 3D building layer or custom 3D models using javascript for the google earth plugin.

My end goal is to be able to have a user select a 3d building and have an information bubble show up with details about that building. This is rather than the default bubble that Google shows with information about the 3D model.

Ideally one would be able to use the 3D buildings layer as opposed to loading the models manually, though I don't have high hopes of that being possible so doing it via manually uploaded 3D models would be a possibility.

I am using the google maps api V3 with the google earth utility library to activate the plugin.

Thanks in advance for any answers.

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

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

发布评论

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

评论(1

向地狱狂奔 2024-12-06 10:28:08

我想我第一次读过这篇文章。仔细一看,发现似乎仍然不可能(以这种简单的方式)

google.earth.addEventListener(placemark, 'click', function(event) 
{ 
  alert('click');
});

...鼠标事件可以附加到插件中的大多数几何图形(3D 模型除外),...

google Earth api

也许可以通过实现自定义交叉点“侦听器”来做到这一点

//编辑:

也许这不是漏洞的故事。更多研究表明,可以针对某些几何体进行命中测试。 ge 接口 有一个名为 hitTest(...) 的函数
API 文档

GEHitTestResult GEView.hitTest( float               x,
                                KmlUnitsEnum        xUnits,
                                float               y,
                                KmlUnitsEnum        yUnits,
                                GEHitTestModeEnum   mode     
                               )    

不幸的是 < code>GEHitTestModeEnum 仅适用于GEPlugin.HIT_TEST_GLOBE GEPlugin.HIT_TEST_TERRAIN
GEPlugin.HIT_TEST_BUILDINGS

因此您可以针对建筑物进行 hitTest,但不能针对自定义 3D 模型进行点击测试...

问题 使用其他“可事件”不可见地标来检测 点击。

命中测试的小代码excample

//EDIT2:

解决方案我在当前项目中使用的听起来像这样:

使用 多边形 用于每个“接收自定义 3D 模型的点击事件”
多边形可以接收点击事件

google.earth.addEventListener(polygonPlacemark, 'click', function(event) {
    alert('placemark bounding box clicked');
});

I think i've overread this the first time. After taking a closer look it reveals that it seems to be still not possible (in that easy way)

google.earth.addEventListener(placemark, 'click', function(event) 
{ 
  alert('click');
});

... Mouse events can be attached to most geometries in the plugin (the exception is 3D models), ...

google earth api

Maybe its possible to do that by implementing a custom intersection 'listener'

//EDIT:

Maybe thats not the hole story. more research revealed that it is possible to make a hittest agaignst some geometry. the ge interface has a function named hitTest(...)
api doc

GEHitTestResult GEView.hitTest( float               x,
                                KmlUnitsEnum        xUnits,
                                float               y,
                                KmlUnitsEnum        yUnits,
                                GEHitTestModeEnum   mode     
                               )    

unfortunately the GEHitTestModeEnum is only suitable for GEPlugin.HIT_TEST_GLOBE GEPlugin.HIT_TEST_TERRAIN
GEPlugin.HIT_TEST_BUILDINGS

so you can hitTest against buildings but not against custom 3D models...

a slightly useable solution to click custom 3D models could be the one described in this issue using other 'eventable' invisible placemarks to detect a click.

litte code excample of hittesting

//EDIT2:

The solution i use in my current project sounds like that:

create a bounding box with polygons for every 'click event recieving custom 3d model'
that polygons can receive click events

google.earth.addEventListener(polygonPlacemark, 'click', function(event) {
    alert('placemark bounding box clicked');
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文