Class Graticule::Geocoder::Multi
In: lib/graticule/geocoder/multi.rb
Parent: Object

Methods

locate   new  

Public Class methods

The Multi geocoder allows you to use multiple geocoders in succession.

  geocoder = Graticule.service(:multi).new(
    Graticule.service(:google).new("api_key"),
    Graticule.service(:yahoo).new("api_key"),
  )
  geocoder.locate '49423' # <= tries geocoders in succession

The Multi geocoder will try the geocoders in order if a Graticule::AddressError is raised. You can customize this behavior by passing in a block to the Multi geocoder. For example, to try the geocoders until one returns a result with a high enough precision:

  geocoder = Graticule.service(:multi).new(geocoders) do |result|
    [:address, :street].include?(result.precision)
  end

Geocoders will be tried in order until the block returned true for one of the results

Public Instance methods

[Validate]