I have an HTML form in my website with a field the GPS coordinates. How can I get the coordinates so that I can plot them on Google Maps, and persist them to a database?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I suggest you look into the Geocoder section of the Google Maps V3 API. I just went through this issue myself. When building your form, include hidden inputs for lat and long (whatever your field names in your db) like this:
In your address input, you will say something like this:
where you include the call to a javascript function called getLatLong().
Here is an example below of the function:
You may need to play around with it a bit. be sure to do a search for the google Geocoder here on SO, as I found my solution with bits and pieces I got straight from this site.