GoogleMapsGeocoder
A simple Plain Old Ruby Object wrapper for geocoding with Google Maps.
Installation
Set your Google Maps API key, which Google now requires, as an environment variable:
export GOOGLE_MAPS_API_KEY=[your key]Add
GoogleMapsGeocoderto your Gemfile and runbundle:gem 'google_maps_geocoder'Or try it out in
irbwith:require './lib/google_maps_geocoder/google_maps_geocoder'
Ready to Go in One Step
= GoogleMapsGeocoder.new '1600 Pennsylvania DC'
Usage
Get the complete, formatted address:
.formatted_address
=> "1600 Pennsylvania Avenue Northwest, President's Park, Washington, DC 20500, USA"
...standardized name of the city:
.city
=> "Washington"
...full name of the state or region:
.state_long_name
=> "District of Columbia"
...standard abbreviation for the state/region:
.state_short_name
=> "DC"
API
The complete, hopefully self-explanatory, API is:
GoogleMapsGeocoder#cityGoogleMapsGeocoder#country_long_nameGoogleMapsGeocoder#country_short_nameGoogleMapsGeocoder#countyGoogleMapsGeocoder#exact_match?GoogleMapsGeocoder#formatted_addressGoogleMapsGeocoder#formatted_street_addressGoogleMapsGeocoder#latGoogleMapsGeocoder#lngGoogleMapsGeocoder#partial_match?GoogleMapsGeocoder#postal_codeGoogleMapsGeocoder#state_long_nameGoogleMapsGeocoder#state_short_name
For compatibility with Geocoder, the following aliases are also available:
GoogleMapsGeocoder#addressGoogleMapsGeocoder#coordinatesGoogleMapsGeocoder#countryGoogleMapsGeocoder#country_codeGoogleMapsGeocoder#latitudeGoogleMapsGeocoder#longitudeGoogleMapsGeocoder#stateGoogleMapsGeocoder#state_code
Contributing to GoogleMapsGeocoder
Copyright
Copyright © 2011-2020 Roderick Monje. See LICENSE.txt for further details.
