So I’m new to both Zend and to Google Maps API, I want to create a form. Where the user inputs an address in a field (probably an field completely outside of the “form”) the address is being looked up on google maps, preferably realtime but could also be done with a “search address” button. When user is happy with shown address, he submits form and address (or long/lat, whatever is best) is extracted from google map api and saved along with additional form data to database. How would this be done in the best way?
Share
The easiest way would be to add two hidden fields to your form (lat/long) and handle the textfield in javascript. So when the user finished typing the address you start an ajax-request and write the resulting lat / long values in the hidden fields.
When submitted you should check the form and look for filled values in the lat / long fields. If they are missing show an error message to the user.