Brazilian, Married, Web Developer.I write in English because I want to reach all the world, but the real intention is to reach my future self.

Jul 25, 2014

Form with GeoLocation

How about automatically fill address information in your form just by getting Geolocation of user?!

Every day we fill out forms on the web, and we know it sucks. For example, why we always have to fill out address information? Why doesn’t the computer simply get my location God knows how!? Some websites made an improvement by getting part of the address by the zip code, but, HTML5 GeoLocation can really improve this user experience.

HTML5 Geolocation can provide the geographic coordinates, and Google Geocoding API can provide the rest of information. You look at Can I Use for the GeoLocation Browser Suport, but for privacy reasons, the user is asked for permission to report location information, so it’s the user’s decicion, automatically fill or not.

Once you have the user’s Geographic Coordinates, you can send a request to Google Geocoding API to get the real information, like city, state and zip code. These information may be wrong, so it’s important to let the input editable. The URL of Google API we’ll use is the Reverse Geocoding, and it’s like that: