Let Google do your thinking.
December 10th, 2008 by Bobby WhitmanA few weeks ago we launched a new site for Charley’s Grilled Subs along with our friends at b&a. One of dynamIt’s many tasks in the project was building a store locator whereby you can search the database of over 350 Charley’s worldwide locations to find one near you.
We have a database of all US zip codes and a database of all the Charley’s locations, each with associated geocoordinates (longitude and latitude). Thus we’re able to calculate a distance radius around any zip code and display all of the places within at which we can get a delicious Philly cheesesteak. But, what if we want to add the ability for people to enter their city, state, country or any combination of the three and still get the benefits of GIFOY.
Suddenly we have to deal with the fact that if one just enters “Columbus” then we may display Columbus, GA results when the user really wants that radius around Columbus, OH. We’d all like to think that when you say Columbus without the state, you mean Ohio, but our database does not know that. Ok, no problem, we have a zip code database that knows the city and state to which it belongs, we can just devise an algorithm to see if multiple matches exist then display options to the user to see which one is intended. This sounds reasonable, right?
Yeah, it does….until you realize that there are 18 states in this country which contain a city named ‘Columbus.’ Eighteen?!?!?! Yes, 18. So, we could go with our first idea and list all 18 asking the user which Columbus they meant, but that isn’t too friendly is it?
Alas, we turn to our comrade-in-arms Google and let them do our thinking for us.
We’ve all used Google maps. We know its fairly simple to find what it is we want when searching the maps for place names. Luckily, Google so kindly provides a simple way to deliver us developers place data (including geocoordinates) given a simple string search query using their Geocoding API.
There it is, take the user input, run it through Google and let them figure out that Columbus, OH is more important than Columbus, GA. Sorry peach-staters, Google has spoken.
