Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

GoogleMapsGeocoder

Build status Code Climate Coverage Status Inline docs Gem Version

A simple Plain Old Ruby Object wrapper for geocoding with Google Maps.

Installation

  1. Set your Google Maps API key, which Google now requires, as an environment variable:

    export GOOGLE_MAPS_API_KEY=[your key]
  2. Add GoogleMapsGeocoder to your Gemfile and run bundle:

    gem 'google_maps_geocoder'

    Or try it out in irb with:

    require './lib/google_maps_geocoder/google_maps_geocoder'

Ready to Go in One Step

chez_barack = GoogleMapsGeocoder.new '1600 Pennsylvania DC'

Usage

Get the complete, formatted address:

chez_barack.formatted_address
 => "1600 Pennsylvania Avenue Northwest, President's Park, Washington, DC 20500, USA"

...standardized name of the city:

chez_barack.city
 => "Washington"

...full name of the state or region:

chez_barack.state_long_name
 => "District of Columbia"

...standard abbreviation for the state/region:

chez_barack.state_short_name
 => "DC"

API

The complete, hopefully self-explanatory, API is:

  • GoogleMapsGeocoder#city
  • GoogleMapsGeocoder#country_long_name
  • GoogleMapsGeocoder#country_short_name
  • GoogleMapsGeocoder#county
  • GoogleMapsGeocoder#exact_match?
  • GoogleMapsGeocoder#formatted_address
  • GoogleMapsGeocoder#formatted_street_address
  • GoogleMapsGeocoder#lat
  • GoogleMapsGeocoder#lng
  • GoogleMapsGeocoder#partial_match?
  • GoogleMapsGeocoder#postal_code
  • GoogleMapsGeocoder#state_long_name
  • GoogleMapsGeocoder#state_short_name

For compatibility with Geocoder, the following aliases are also available:

  • GoogleMapsGeocoder#address
  • GoogleMapsGeocoder#coordinates
  • GoogleMapsGeocoder#country
  • GoogleMapsGeocoder#country_code
  • GoogleMapsGeocoder#latitude
  • GoogleMapsGeocoder#longitude
  • GoogleMapsGeocoder#state
  • GoogleMapsGeocoder#state_code

Contributing to GoogleMapsGeocoder

Cheers!

Buy Me A Coffee

Copyright

Copyright © 2011-2021 Roderick Monje. See LICENSE.txt for further details.

About

A simple PORO wrapper for geocoding with Google Maps.

Topics

Resources

License

Packages

No packages published

Languages