HTML5 Geolocation and Ruby Geocoder


Recently, I needed to figure out how to get the location of the user’s mobile device in order to serve up location specific content.

HTML5 Geolocation feature allows you to get the longitude/latitude coordinates of the user.

This will provide the longitude/latitude location of the mobile device using the device’s native GPS functionality. With the coordinates, I can pass it to the geocoder gem to find out the city, state, country, etc. If we know the location, we can serve up a specific content depending on location.