Skip to content
Snippets Groups Projects
Commit b5c8ccf1 authored by Alex Reisner's avatar Alex Reisner
Browse files

Add result language configuration.

parent 6ae63b61
No related branches found
No related tags found
No related merge requests found
......@@ -163,6 +163,15 @@ You can set the timeout used for connections to the geocoding service. The defau
# config/initializers/geocoder.rb
Geocoder::Configuration.timeout = 5
=== Language
You can set the language used for reverse geocoding results to German, for example, by setting the following:
# config/initializers/geocoder.rb
Geocoder::Configuration.language = :de
For a list of supported languages see the documentation for the geocoding service you're using.
== Forward and Reverse Geocoding in the Same Model
......
module Geocoder
class Configuration
# geocoding service timeout (secs)
def self.timeout; @@timeout; end
def self.timeout=(obj); @@timeout = obj; end
# name of geocoding service (symbol)
def self.lookup; @@lookup; end
def self.lookup=(obj); @@lookup = obj; end
# ISO-639 language code
def self.language; @@language; end
def self.language=(obj); @@language = obj; end
# app id (if using Yahoo geocoding service)
def self.yahoo_appid; @@yahoo_appid; end
def self.yahoo_appid=(obj); @@yahoo_appid = obj; end
end
......@@ -13,4 +21,5 @@ end
Geocoder::Configuration.timeout = 3
Geocoder::Configuration.lookup = :google
Geocoder::Configuration.language = :en
Geocoder::Configuration.yahoo_appid = ""
......@@ -22,7 +22,8 @@ module Geocoder::Lookup
def query_url(query, reverse = false)
params = {
(reverse ? :latlng : :address) => query,
:sensor => "false"
:sensor => "false",
:language => Geocoder::Configuration.language
}
"http://maps.google.com/maps/api/geocode/json?" + hash_to_query(params)
end
......
......@@ -20,6 +20,7 @@ module Geocoder::Lookup
:location => query,
:flags => "JXTSR",
:gflags => "AC#{'R' if reverse}",
:locale => "#{Geocoder::Configuration.language}_US",
:appid => Geocoder::Configuration.yahoo_appid
}
"http://where.yahooapis.com/geocode?" + hash_to_query(params)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment