Hi.

Here's some code i've used recently that you should be able to modify
to your needs:

//      map must be global
//      and assume you have a form with an id 'myFormId' which has two text
inputs with names 'lat' and 'lng'
function getMapClick(){
        //      get the LatLng of the map click and complete the search form's
address box with that value to 4 decimal places
        var listener=google.maps.event.addListener(map, 'click',
function(clickEvent){
                var myForm=document.forms.myFormId, latLng=clickEvent.latLng,
lat=latLng.lat(), lng=latLng.lng();
                myForm.lat.value=lat;
                myForm.lng.value=lng;
                //      remove the event listener
                google.maps.event.removeListener(listener);
                listener=null;
        });
};

You could use a button or anchor to call the function:

<a href="javascript:void(0)" onclick=getMapClick()">Enable map click</
a>

Martin.


On 21 Sep, 12:46, Peter <[email protected]> wrote:
> I want users to be able to click on a worldmap. Then, when theyu click
> I get the longitude and latitude of the clicked location and store
> them in two textboxes...
> Where can I find how to do that?

-- 
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