Thanks for the helpful reply Martin. For a second thought, isn't this going to 
return every click on the map? It's impossible to figure which click is when 
the user want to pick a particular spot. Can we trigger the function if the 
click for example last for 2 seconds ? What are other solutions for this case 
does the API offer?
-----Original Message-----
From: Martin <[email protected]>
Sender: [email protected]
Date: Wed, 8 Dec 2010 22:57:10 
To: Google Maps JavaScript API v3<[email protected]>
Reply-To: [email protected]
Subject: [Google Maps API v3] Re: How to get LatLng input from a user click ?

Hi.

You can add an event listener to your map listening for the 'click'
event.

google.maps.event.addListener(myMap, 'click', function(myEvent){
var myClickLatLng=myEvent.latLng;
// now process myClickLatLng
});

That 'pseudo code' assumes your map object is named myMap, on a map
click the function executes and is passed a MouseEvent object which
has a latLng property - where the user clicked on the map.

http://code.google.com/apis/maps/documentation/javascript/reference.html#Map
Scroll down to the Map Events section.

http://code.google.com/apis/maps/documentation/javascript/reference.html#MouseEvent

http://code.google.com/apis/maps/documentation/javascript/reference.html#MapsEventListener

Martin.


On Dec 9, 6:44 am, Mesh3L <[email protected]> wrote:
> Hello,
>
> I'm not very familiar with JavaScript. Let's say that I want the user
> to be able to chose a spot on the map (a mouse click), and than to have
> back the LatLng of that spot in order to save it an a database. I read
> the reference and i can see that the answer is around there but as i
> said, my knowledge in JavaScript didn't help.
>
> I will appreciate it if someone can assist me on this. Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to