Google Earth Plugin Click Events in 3D Buildings

I look around and have not yet found an answer to this. Is it possible to add click events on a three-dimensional building layer or custom 3D models using javascript for the google earth plugin.

My ultimate goal is to be able to choose a third building and create an information bubble with details about this building. This is probably not the default bubble that Google displays with information about the 3D model.

Ideally, you could use a 3D building layer as opposed to loading models manually, although I have no great hope that this is possible, so it would be possible to do this using manually loaded 3D models.

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

Thanks in advance for any answers.

+4
source share
1 answer

I think the first time I tried it. After a closer look, he shows that this seems impossible (in such a simple way)

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

... Mouse events can be tied to most of the geometries in the plugin (exception - 3D models), ...

google earth api

Perhaps this can be done by implementing a custom listener hook

// EDIT:

Perhaps this is not a story of holes. more research has shown that you can do hittest agaignst of some geometry. ge interface has a function called hitTest(...) api doc

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

Unfortunately, GEHitTestModeEnum is only suitable for GEPlugin.HIT_TEST_GLOBE GEPlugin.HIT_TEST_TERRAIN GEPlugin.HIT_TEST_BUILDINGS

so you can strike at buildings, but not against custom 3D models ...

You can use several user-friendly 3D models described in this issue , using other “meaningful” invisible labels to detect clicks.

litte code excample hittesting

// EDIT2:

The solution that I am using in my current project is:

create a bounding box with polygons for each click event that receives a custom 3d model that polygons can receive click events

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

All Articles