cfpb/owning-a-home — pull request #13 by contolini (2014-04-29 06:28:10+00:00)
Title: Add intelligent location default

Auto-populating the user's state is tricky. The [geolocation API](https://developer.mozilla.org/en-US/docs/WebAPI/Using_geolocation) only returns latitude and longitude coordinates. Finding the state from the coordinates would require making a request to a third-party geocoding service (Google, Bing, Yahoo, etc.). We can do this but it's a Pain In The Butttm.

A fast but admittedly not 100% accurate solution is to compare the user's coordinates to the centroid of each state. Default to whichever centroid is closet to the user's coordinates. That's what I'm doing in the [geolocation module](https://github.com/contolini/owning-a-home/blob/master/src/static/js/modules/geolocation.js). It's decently accurate except when a user is close to the edge of an oddly-shaped state. Then it may default to an adjacent state.

I don't feel accuracy is of utmost importance because if the user is on a border they could be looking to buy a house in a neighboring state anyway. I think it's fine for us to make an educated guess.

@ascott1 @efortiz Thoughts?