Get address from Geocode latitude and longitude

user2184718 picture user2184718 · Dec 29, 2013 · Viewed 10.6k times · Source

For the bulk of my application, I am getting the latitude, longitude, postal code, etc of a town/city from Geocoder. I am just putting in the city and state and in return I am getting

I am in a scenario where I have a venue. That venue needs an address and I am getting that venues latitude and longitude from another source. Using the Geocoder gem, am I able to get an address by giving it a latitude and longitude?

Answer

rplaurindo picture rplaurindo · Apr 19, 2016

Run in Rails console.

latitude = 40.0397
longitude = -76.30144
geo_localization = "#{latitude},#{longitude}"
query = Geocoder.search(geo_localization).first
query.address