项目作者: ivanoblomov

项目描述 :
A simple PORO wrapper for geocoding with Google Maps.
高级语言: Ruby
项目地址: git://github.com/ivanoblomov/google_maps_geocoder.git
创建时间: 2011-04-13T15:51:23Z
项目社区:https://github.com/ivanoblomov/google_maps_geocoder

开源协议:MIT License

下载


GoogleMapsGeocoder

Build status
Code Climate
Coverage Status
OpenSSF Best Practices
OpenSSF Scorecard
Gem Version

A simple Plain Old Ruby Object wrapper for geocoding with Google Maps, GoogleMapsGeocoder gives you all its geocoding functionality with these advantages:

Installation

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

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

    1. gem 'google_maps_geocoder'

    Or try it out in irb with:

    1. require 'google_maps_geocoder'

Security note

GoogleMapsGeocoder is cryptographically signed. To insure the gem you install hasn’t been tampered with, add my public key as a trusted certificate and then install:

  1. gem cert --add <(curl -Ls https://raw.github.com/FoveaCentral/google_maps_geocoder/master/certs/ivanoblomov.pem)
  2. gem install google_maps_geocoder -P HighSecurity

Ready to Go in One Step

  1. chez_barack = GoogleMapsGeocoder.new 'White House'

Usage

Get the complete, formatted address:

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

…standardized name of the city:

  1. chez_barack.city
  2. => "Washington"

…full name of the state or region:

  1. chez_barack.state_long_name
  2. => "District of Columbia"

…standard abbreviation for the state/region:

  1. chez_barack.state_short_name
  2. => "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

Documentation

Complete RDoc documentation is available at RubyDoc.info.

Contributing to GoogleMapsGeocoder

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