I'm looking for a way to allow a user to place a marker on a Google map and then get the co-ordinates so I can email them to a user.
Is it possible to allow users to do this on the fly? I've seen here and understand I can do this using longitude and Latitude. So using the above method can I get a Longitude and Latitude from a users click?
You can achieve this using the following code:
google.maps.event.addListener(map, 'click', function( event ){
alert( "Latitude: "+event.latLng.lat()+" "+", longitude: "+event.latLng.lng() );
});
The map
variable is your google.maps.Map instance. Every time the user clicks the map an alert box will display the coordinates of the place he clicked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With