I don't think Google Maps for Rails does this out of the box. I ended up using Google Maps for Rails for taking care of generating the map, and using the Geocoder gem to do geocoding and scoping my data points.
With both gems, in my model I have:
class Store < ActiveRecord::Base
acts_as_gmappable
private
def gmaps4rails_address
"#{address_line_1}, #{self.city}, #{self.region}, #{self.postal_code}, #{self.country}"
end
end
In my controller I have:
def index
if params[:search]
@stores = Store.near(params[:search], 20)
@json = @stores.to_gmaps4rails
else
@stores = Store.all
@json = @stores.to_gmaps4rails
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @stores }
end
end
This seems to be working just fine, but I'll leave this question open a bit in case there's a better answer.