Finds latitude and longitude for given address
Add this line to your application's Gemfile:
gem 'latlong'
And then execute:
$ bundle
Or install it yourself as:
$ gem install latlong
In order to fetch coordinates for address, do this:
require 'latlong'
Latlong.configure do |config|
config.provider = :yandex # or :google by default
end
results = Latlong.location 'Sacramento' # returns array of items with
# coordinates and address
results.first.address # 'Sacramento, US'
results.first.lat # 38.5815719
results.first.lon # -121.4943996
Also possible to enable caching for requests through redis:
require 'latlong'
require 'redis'
Latlong.configure do |config|
config.provider = :yandex # or :google by default
config.cache = true
end
- Fork it ( https://github.com/r-ideas/latlong/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request