Hello, I'm doing a project in Ruby on Rails where I need to implement a local search engine. I have a database of businesses and their addresses (street city state zip) and I need to figure out how to do a distance based search.
A visitor to the site should be able to search by street address or zip code, and receive results of the businesses that are close to the query address, sorted by proximity, along with a google map.
Are there any API's or services out there that will do the calculations? How do I begin to implement such a system?
I would go to rubygems.org and search for available gems, or github.com for available plugins.
Do you have any names in mind? I've been looking around for a solution, I checked rubygems and github but didn't come up with anything.
Programmatically, how would you implement location based search, given only a zip code or street address? I'd imagine I'd have to tie in to a service like google maps. I skimmed through the API but so far haven't found anything helpful since the search has to be performed on my database, rather than Google's index.
Any more ideas would be great, thanks.
I think this gem would help you. http://rubygems.org/gems/geokit Based on the documentation http://geokit.rubyforge.org/ it has Active Record distance based finders that will let you find all the points in your db within a 50-mile radius.
There is an example app on github using the geokit and google-maps gems. http://github.com/johnsonch/google_maps_and_geokit_demo
I've not used either of these before, and will not be able to comment on how to use them, but they seem like they will help with what you are trying to do.
Please let me know if this is what you were looking for.
OMG this is perfect thank you!