views:

487

answers:

2

I've used GeoKit and acts_as_geocodable in the past. I like GeoKit, but its missing nicer features like named_scopes. I'm not a huge fan of acts_as_geocodable because it duplicates address data into its own table.

Lately, these gems seem under-maintained.

What are some actively maintained gems out there?

+4  A: 

I maintain the rails-geocoder gem:

http://gemcutter.org/gems/rails-geocoder

Source code:

http://github.com/alexreisner/geocoder

I can tell you it's actively maintained because I'm working on Rails 3 compatibility as I write this! It's designed to be very simple, while providing the most commonly-used geocoding features. It provides named scopes and doesn't duplicate any data.

Alex Reisner
Hey that looks nice. I'll give it a shot. Just a quick question: how do I circumvent geocoding if the street address is blank? Does geocoded_by accept an :if option? Or should I call fetch_coordinates in before_save and put the conditional in there?
cotopaxi
This may be the default behavior in a future version but for now, yes, add an `:if` option to `before_save`.
Alex Reisner
That would be a nice feature to have. Thanks for your hard work.
cotopaxi
I was able to implement it easily (only did geocoding, no distance stuff yet) and your code is nice and clean. Thanks again!
cotopaxi
Thanks! Glad you like it so far. If you install the plugin version (`script/plugin install http://github.com/alexreisner/geocoder.git`) you won't need your `:if` option--it doesn't query Google if the search term (address) is blank. This will be in the next gem release too but that won't be for a few days.
Alex Reisner
A: 

Amazing job on the gem! I've used geokit before but its a real pain with rails 3.
I have 2 questions if it's not too much trouble.

1) Is it possible to do something like this Location.near([lat, lng], 20).order("distance ASC")?
I've had that problem with acts_as_geocodable where it wouldn't recognize the "distance" and couldn't order by it.

2) Say I have a Company model which has many Addresses in the Address Model, how would I have everything geocode in the Address model, but search for Companies within a certain distance from a zipcode?

Any help will be appreciated. Thank you.

felixg