Skip to content

Instantly share code, notes, and snippets.

@huertanix
Created March 15, 2011 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huertanix/870171 to your computer and use it in GitHub Desktop.
Save huertanix/870171 to your computer and use it in GitHub Desktop.
A full example on how to get latitude and longitude from SimpleGeo's Place API with a US postal address.
# Using Ruby 1.9.2
require 'simplegeo'
require 'json'
full_address = "960 West University Dr #103 Tempe, AZ"
geo_options = {'radius' => 0.1}
closest_locations = SimpleGeo::Client.get_places_by_address(full_address, geo_options)
coordinates = JSON.parse(closest_locations.to_json)['features'][0]['geometry']['coordinates']
longitude = coordinates[0]
latitude = coordinates[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment