Handle mouse click on screenoverlay

112 views
Skip to first unread message

dinther

unread,
Apr 4, 2009, 8:50:29 PM4/4/09
to KML Developer Support - Google Earth Plug-in
How can I detect a mouse click on a screenoverlay?

This code will let me detect all mouse clicks:

google.earth.addEventListener(ge.getWindow(), "click", doMouseClick);

so reading the documentation it appears that I should be able to hook
up an event handler on a screenoverlay like this:

myScreenOverlay = ge.createScreenOverlay('');
//do the stuff to assign an icon and place it. All no problem.

google.earth.addEventListener(myScreenOverlay, "click", doMouseClick);

But this doesn't work. Can someone show me an example of handling
mouse events on screenoverlays please?

I did find the example of handling the mouse even on a placemark
( http://earth-api-samples.googlecode.com/svn/trunk/examples/event-placemark.html
) but it appears doing the same of a screenoverlay is either not
possible or is done differently

Any help is much appreciated.

Mano

unread,
Apr 8, 2009, 12:51:47 PM4/8/09
to KML Developer Support - Google Earth Plug-in
Hi dinther,

ScreenOverlays are not clickable. This is true in Google Earth as well
as in the plugin. You could detect the mouses position when a click
happens and determine if it is over the ScreenOverlay, but you risk
interfering with the clicks on other objects.

Mano

On Apr 4, 5:50 pm, dinther wrote:
> How can I detect a mouse click on a screenoverlay?
>
> This code will let me detect all mouse clicks:
>
> google.earth.addEventListener(ge.getWindow(), "click", doMouseClick);
>
> so reading the documentation it appears that I should be able to hook
> up an event handler on a screenoverlay like this:
>
> myScreenOverlay = ge.createScreenOverlay('');
> //do the stuff to assign an icon and place it. All no problem.
>
> google.earth.addEventListener(myScreenOverlay, "click", doMouseClick);
>
> But this doesn't work. Can someone show me an example of handling
> mouse events on screenoverlays please?
>
> I did find the example of handling the mouse even on a placemark
> (  http://earth-api-samples.googlecode.com/svn/trunk/examples/event-plac...
Reply all
Reply to author
Forward
0 new messages