Ctrl click event listener

143 views
Skip to first unread message

Yiannis

unread,
Nov 3, 2008, 12:25:30 PM11/3/08
to KML Developer Support - Google Earth Browser Plugin
Hi everyone, i want to catch the ctrl+click event on linestrings and
do some stuff.
Is it possible to create an event listener for this kind of event?

fraser

unread,
Nov 4, 2008, 9:01:09 AM11/4/08
to KML Developer Support - Google Earth Browser Plugin
Hi Yiannis,

Unfortunately there are no events at all for linestrings - only for
placemarks, the globe and the window.
Incidentally you can detect ctrl+click for these by using something
like the following...

--------------------------------------------------------
google.earth.addEventListener(ge.getGlobe(), "mousedown",
globeEventListener);
function globeEventListener(kmlEvent) {
var ctrlKey = kmlEvent.getCtrlKey();
var hitGlobe = kmlEvent.getDidHitGlobe();
if(1==ctrlKey && 1==hitGlobe)
{
alert("Ctrl+click on globe")
}
}
--------------------------------------------------------

See this page for more info:
http://code.google.com/apis/earth/documentation/introduction.html#events

Regards,

Fraser.

Yiannis

unread,
Nov 4, 2008, 12:43:25 PM11/4/08
to KML Developer Support - Google Earth Browser Plugin
Hi fraser,

I followed your recommendation to create something like this:
google.earth.addEventListener(placemark, "mousedown",
myEventListener);
function myEventListener(kmlEvent) {
var ctrlKey = kmlEvent.getCtrlKey();
if(1==ctrlKey)
{
alert("Ctrl+click on placemark")
}
kmlEvent.preventDefault();
}
When i ctrl+click a placemark and the placemark is a marker the alert
box appears but when the placemark is a polyline or a polygon the GE
default behaviour occurs ( an info balloon appears) and the alert box
doesn't pop up..
My goal is to detect the ctrl+click event on polygons and polylines
and override the info balloon. Can this be accomplished?

Regards,

Yiannis

Roman N

unread,
Nov 4, 2008, 7:01:56 PM11/4/08
to KML Developer Support - Google Earth Browser Plugin
Hi Yiannis,

As Fraser said, that's currently not possible without manual hit-
testing... i.e. given a latitude and longitude, determine if a
linestring or polygon is near that point.

We have a feature request for this at:

http://code.google.com/p/earth-api-samples/issues/detail?id=66

You can star the feature to receive email notifications when updates
are available.

- Roman
Reply all
Reply to author
Forward
0 new messages