Search code examples
google-maps-api-3geocodinggmaps4rails

'Lazy' geocoding


Is there any feature in gmaps4rails to process 'lazy' geocoding?

My situation:

I have a database of companies, which has one address. When a company is added manually (only 1 record), there aren't any problems, process_geocoding is set to true by default.

Once every two weeks, we update our db with an import script. When we use import, we set process_geocoding to false, because geocoding slows our import script by 4 - 5 times (in my case - it is unacceptable).

I need lazy a gecoding feature, which can process geocoding if !address.blank? && lat.blank? && lng.blank?


Solution

  • Since 1.5 you can do:

    process_geocoding: lambda { |obj| !obj.address.blank? && obj.lat.blank? && obj.lng.blank? }
    

    or:

    process_geocoding: :method_name