Sha256: e735ee714fac81d6ad8483d48d65d62485e7da64637e134300c9566c261909c5

Contents?: true

Size: 982 Bytes

Versions: 8

Compression:

Stored size: 982 Bytes

Contents

# To extend the Geocoder with additional lookups that come from the application,
# not shipped with the gem, define a "child" lookup in your application, based on existing one.
# This is required because the Geocoder::Configuration is a Singleton and stores one api key per lookup.

# in app/libs/geocoder/lookup/my_preciousss.rb
module Geocoder::Lookup
  class MyPreciousss < Google
  end
end

# Update Geocoder's street_services on initialize:
# config/initializers/geocoder.rb
Geocoder::Lookup.street_services << :my_preciousss

# Override the configuration when necessary (e.g. provide separate Google API key for the account):
Geocoder.configure(my_preciousss: { api_key: 'abcdef' })

# Lastly, search using your custom lookup service/api keys
Geocoder.search("Paris", lookup: :my_preciousss)

# This is useful when we have groups of users in the application who use Google paid services
# and we want to properly separate them and allow using individual API KEYS or timeouts.

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
geocoder-1.8.5 examples/app_defined_lookup_services.rb
geocoder-1.8.4 examples/app_defined_lookup_services.rb
geocoder-1.8.3 examples/app_defined_lookup_services.rb
geocoder-1.8.2 examples/app_defined_lookup_services.rb
geocoder-1.8.1 examples/app_defined_lookup_services.rb
geocoder-1.8.0 examples/app_defined_lookup_services.rb
geocoder-1.7.5 examples/app_defined_lookup_services.rb
geocoder-1.7.4 examples/app_defined_lookup_services.rb