Coder Social home page Coder Social logo

thomasjoyce / google-geo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grossbart/google-geo

1.0 1.0 1.0 148 KB

A simple, dependency-free library for geocoding, reverse geocoding and embedding street views from Google.

Home Page: http://wiki.github.com/greatseth/google-geo

License: Other

google-geo's Introduction

Google::Geo

A simple, elegant library for getting geocoding information from Google Maps. Very much inspired by the google-geocode gem, but completely dependency free!

Installation

$ gem install google-geo -s http://gemcutter.org

Examples

geo = Google::Geo.new API_KEY addresses = geo.locate ‘1600 Amphitheatre Parkway, Mountain View, CA’ addresses.size # 1, :locate always returns an Array address = addresses.first address.country # ‘US’ address.city # ‘Mountain View’ address.full_address # ‘1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA’ address.query # ‘1600 Amphitheatre Parkway, Mountain View, CA’ address.accuracy # 8 address.coordinates # [-122.084143, 37.421972, 0.0]

In the case of sufficiently vague queries, Google::Geo will return more than one:

addresses = geo.locate ‘hell’ addresses.size # 2 addresses.map { |a| a.state } # [‘PA’, ‘NC’]

You can reverse geocode:

address = geo.locate(33.998671, -118.075926).first address.city # => Pico Rivera address.state # => CA address.zip # => 90660 address.country # => US address.full_address # => 4952-4958 Tobias Ave, Pico Rivera, CA 90660, USA

You can optionally enable the ability to get street view embed HTML for an Address:

require “google/geo/address/street_view” address.street_view_html :id => :street_view, :style => “width:640px; height:480px”

Options

If you need to get the results in another language, you can set it like so:

geo = Google::Geo.new API_KEY, “de” geo.language = “en”

The language code can be anything listed on http://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1.

Contributors

License

© 2007-2009 Seth Thomas Rasmussen and released under the WTFPL. See the LICENSE file for details.

google-geo's People

Contributors

fernyb avatar greatseth avatar grossbart avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.