Google Earth API Samples - Placemark Click Event Handling

Last Modified:
08/04/08

Relevant Code Excerpt:

// listen to the click event
google.earth.addEventListener(placemark, 'click', function(event) {
  var text = 'Click:';

  function addToMessage(append1, append2) {
   text += ' ' + append1 + ': ' + append2 + '\n' ;
  }

  addToMessage('target type', event.getTarget().getType());
  addToMessage('currentTarget type',
               event.getCurrentTarget().getType());
  addToMessage('button', event.getButton());
  addToMessage('clientX', event.getClientX());
  addToMessage('clientY', event.getClientY());
  addToMessage('screenX', event.getScreenX());
  addToMessage('screenY', event.getScreenY());
  addToMessage('latitude', event.getLatitude());
  addToMessage('longitude', event.getLongitude());
  addToMessage('altitude', event.getAltitude());
  addToMessage('didHitGlobe', event.getDidHitGlobe());
  addToMessage('altKey', event.getAltKey());
  addToMessage('ctrlKey', event.getCtrlKey());
  addToMessage('shiftKey', event.getShiftKey());
  addToMessage('timeStamp', event.getTimeStamp());

  // Prevent default balloon from popping up for marker placemarks
  event.preventDefault();

  alert(text);
});
      
Show details Hide details Change log r22 by api.roman.public on Aug 20, 2008 Diff Moved projections.js to lib, added example thumbnails, housekeeping Go to: Older revisions r17 by api.roman.public on Aug 04, 2008 Diff Renamed Drive Simulator to Driving Simulator, cleaned up useless svn:executable props r12 by api.roman.public on Jul 29, 2008 Diff Added svn:mime-type for mini examples r11 by api.roman.public on Jul 29, 2008 Diff Added executable property to small code samples All revisions of this file File info Size: 5227 bytes, 148 lines View raw file File properties svn:mime-type text/html