From c5e125747f3549e4e091c1d45e9a2208a749450c Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 23 Oct 2020 13:09:59 +0100 Subject: [PATCH] Allow Geocoder to be configured to use different APIs. This gives instances the option to use other geocoding services, for example MapBox because instances may not have a Google Maps API key if they are using Open Street Map for their map instead of Google. --- config/initializers/geocoder.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index 67ae27e7e4..40ac58adab 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -1,7 +1,9 @@ # Google requires an API key with a billing account to use their API. # The key is stored in config/application.yml. + Geocoder.configure( - lookup: :google, + timeout: ENV.fetch('GEOCODER_TIMEOUT', 3).to_i, + lookup: ENV.fetch('GEOCODER_SERVICE', :google).to_sym, use_https: true, - api_key: ENV.fetch('GOOGLE_MAPS_API_KEY', nil) + api_key: ENV.fetch('GEOCODER_API_KEY', ENV["GOOGLE_MAPS_API_KEY"]) )