I have my own database that includes: address
, lat
, long
, name
.
I have all the addresses that I want without their coordinates. Is there a way to find the coordinates in order to use them as markers on my active map?
In other words I want something to batch?! geocode my addresses that are already in to my database.
Thank you very much
Edited:
def index
if params[:search].present?
@locations = Location.near(params[:search], 20, :order => :distance)
else
@locations = Location.all
@locations.each do |l|
if l.latitude.nil?
new_location = "#{l.address}"
s = Geocoder.search(new_location)
l.latitude = s[0].latitude
l.longitude = s[0].longitude
l.save
end
end
end
This is what I have, but it updates only my first address on the database.