4

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.

Charles
  • 50,943
  • 13
  • 104
  • 142
Vigoren
  • 41
  • 3
  • unfortunately simply adding seams to be not working. aint able to find the right place in the docs where this is discussed google.earth.addEventListener(placemark, 'click', function(event) { alert('click');}); if you get this solved or a real statment about this in the docs or any other valid source i would appreciate this :) – dustin.b Aug 17 '11 at 14:07
  • i've found this http://groups.google.com/group/google-earth-browser-plugin/browse_thread/thread/13c6a20d23306d4f?pli=1 someone is arguing that its not possible but its from '08 that issue ticked linked in that post is sadly not available .. maybe they added this functionality – dustin.b Aug 17 '11 at 14:18

1 Answers1

0

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');
});
dustin.b
  • 1,275
  • 14
  • 33