Google Maps: adding a marker on a right click

Dear Lazyweb,

Ok, it’s late and I may be missing something obvious. I want to add a marker on a right click on a Google Map. The code works ok on a normal (left) click:

but doesn’t do a thing on a right click. What did I miss?

(there are no errors signaled by firebug, this correctly refers to the map object and the point is ok too).

Update: What is it only after I post that I find the answer to my question? So, for some reason, in a normal (left) click, the GMarker wants a container position (which is what is given as parameter). But with a right click, the GMarker would require a latitude/longitude object (by calling fromContainerPixelToLatLng with the point). But if give a GLatLng to the GMarker in the left click event, it incorrectly positions the icon. Nice! (or not so much…).

Comments are closed.