Class: Geocoder::Lookup::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/geocoder/lookups/base.rb

Direct Known Subclasses

Bing, Freegeoip, GeocoderCa, Google, Nominatim, Test, Yahoo, Yandex

Instance Method Summary collapse

Instance Method Details

Return the URL for a map of the given coordinates.

Not necessarily implemented by all subclasses as only some lookups also provide maps.



42
43
44
# File 'lib/geocoder/lookups/base.rb', line 42

def map_link_url(coordinates)
  nil
end

#search(query, options = {}) ⇒ Object

Query the geocoding API and return a Geocoder::Result object. Returns nil on timeout or error.

Takes a search string (eg: “Mississippi Coast Coliseumf, Biloxi, MS”, “205.128.54.202”) for geocoding, or coordinates (latitude, longitude) for reverse geocoding. Returns an array of Geocoder::Results.



27
28
29
30
31
32
33
34
# File 'lib/geocoder/lookups/base.rb', line 27

def search(query, options = {})
  query = Geocoder::Query.new(query, options) unless query.is_a?(Geocoder::Query)
  results(query).map{ |r|
    result = result_class.new(r)
    result.cache_hit = @cache_hit if cache
    result
  }
end