Class: Geocoder::Lookup::Base
- Inherits:
-
Object
- Object
- Geocoder::Lookup::Base
- Defined in:
- lib/geocoder/lookups/base.rb
Direct Known Subclasses
Bing, Freegeoip, GeocoderCa, Google, Mapquest, Nominatim, Test, Yahoo, Yandex
Instance Method Summary collapse
-
#map_link_url(coordinates) ⇒ Object
Return the URL for a map of the given coordinates.
-
#search(query, options = {}) ⇒ Object
Query the geocoding API and return a Geocoder::Result object.
Instance Method Details
#map_link_url(coordinates) ⇒ Object
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::Result
s.
27 28 29 30 31 32 33 34 |
# File 'lib/geocoder/lookups/base.rb', line 27 def search(query, = {}) query = Geocoder::Query.new(query, ) unless query.is_a?(Geocoder::Query) results(query).map{ |r| result = result_class.new(r) result.cache_hit = @cache_hit if cache result } end |