listening to DOM events

Listen to DOM events and do something when fired.

function initialize() {
  var mapOptions = {
    zoom: 8,
    center: new google.maps.LatLng(-34.397, 150.644),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var mapDiv = document.getElementById(\'map-canvas\');
  var map = new google.maps.Map(mapDiv, mapOptions);

   We add a DOM event here to show an alert if the DIV containing the
   map is clicked. Note that we do this within the intialize function
   since the document object isn\'t loaded until after the window.load
   event.
  google.maps.event.addDomListener(mapDiv, \'click\', showAlert);
}

function showAlert() {
  window.alert(\'DIV clicked\');
}

google.maps.event.addDomListener(window, \'load\', initialize);