geokit / geokit-rails

Official Geokit plugin for Rails/ActiveRecord. Provides location-based goodness for your Rails app. Requires the Geokit gem.
MIT License
1.57k stars 245 forks source link

how can we access distance field? #136

Closed hcyildirim closed 5 years ago

hcyildirim commented 6 years ago

Hi, I want to show the distance between the locations that exist in the database of latitude and longitude values I sent to the query. How can we access this distance information?

example:

@locations = Location.within(5, :origin => @somewhere)

distance value should be calculated by @somewhere coordinates and returns like below:

{
  "data": [
    {
      "name": "Paris",
      "distance": "200 meters"
    },
    {
      "name": "New York",
      "distance": "2000 meters" 
    }
  ]
}

https://stackoverflow.com/questions/51184453/how-can-we-access-distance-field-on-calculated-ar-instances

hcyildirim commented 5 years ago

There is a patch in https://github.com/geokit/geokit-rails/issues/56