Google maps right click event error

Hi,

I am trying to add a right click event to the google maps.  I cannot see alert with the geocodes.
I am not sure what to change.


var map;


var directionsDisplay;
var directionsService = new google.maps.DirectionsService();

function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
  var mapOptions = {
    zoom: 8,
    center: new google.maps.LatLng(-34.397, 150.644),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

  map = new google.maps.Map(document.getElementById('mapsGoogle'),
      mapOptions);
      directionsDisplay.setMap(map);
      directionsDisplay.setPanel(document.getElementById('directions-panel'));
      HomeTestMarker();

}

 google.maps.event.addListener(map, 'rightclick', function(event ) {
         var lat = event.latLng.lat();
         var lng = event.latLng.lng();
        alert("Lat=" + lat + "; Lng=" + lng);
    });

Open in new window

shahjagatAsked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
put line 23 to 27 inside the initialize function (line 23 is good)
test page : http://jsfiddle.net/7vqrc/
0
 
shahjagatAuthor Commented:
leakim971, it worked.
Do you need to have all the events inside initialize?
0
 
leakim971PluritechnicianCommented:
for click on the map, yes
0
 
shahjagatAuthor Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.