lib/geokit/geocoders/yandex.rb in geokit-1.8.0 vs lib/geokit/geocoders/yandex.rb in geokit-1.8.1
- old
+ new
@@ -1,10 +1,12 @@
module Geokit
module Geocoders
# Yandex geocoder implementation. Expects the Geokit::Geocoders::YANDEX variable to
# contain a Yandex API key (optional). Conforms to the interface set by the Geocoder class.
class YandexGeocoder < Geocoder
+ config :key
+
private
# Template method which does the geocode lookup.
def self.do_geocode(address)
address_str = address.is_a?(GeoLoc) ? address.to_geocodeable_s : address
@@ -14,10 +16,10 @@
parse :json, res.body
end
def self.submit_url(address_str)
url = "http://geocode-maps.yandex.ru/1.x/?geocode=#{Geokit::Inflector::url_escape(address_str)}&format=json"
- url += "&key=#{Geokit::Geocoders::yandex}" if Geokit::Geocoders::yandex
+ url += "&key=#{key}" if key
url
end
def self.parse_json(result)
loc = GeoLoc.new