Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps API 3: Get Coordinates from Right-Click

I have 2 text boxes for lat and lon for when a user is entering a new record to the db.

I have a live preview of Google Maps that works great, now what I want to do is add a right-click event on the map that populates the lat/lon text boxes with the coord clicked.

Is this even possible?

I know how to add the event listener, and looked through the API docs, but didn't see anything that does this. I know you can do it on google's map on their website.

like image 748
guyfromfl Avatar asked Oct 26 '11 16:10

guyfromfl


1 Answers

google.maps.event.addListener(map, "rightclick", function(event) {     var lat = event.latLng.lat();     var lng = event.latLng.lng();     // populate yor box/field with lat, lng     alert("Lat=" + lat + "; Lng=" + lng); }); 
like image 160
Jiri Kriz Avatar answered Sep 21 '22 21:09

Jiri Kriz