I have a form that a user needs to fill out where the location needs to be identified. I have latitude and longitude input fields on the form. I am also looking for the de
Using the Google Maps API, you can do this pretty easily. Just add a click event handler to your map object, which passes in the latitude/longitude coordinates of where the user clicked (see details on the click
event here).
function initMap()
{
// do map object creation and initialization here
// ...
// add a click event handler to the map object
GEvent.addListener(map, "click", function(overlay, latLng)
{
// display the lat/lng in your form's lat/lng fields
document.getElementById("latFld").value = latLng.lat();
document.getElementById("lngFld").value = latLng.lng();
});
}