geokit / geokit-rails

Official Geokit plugin for Rails/ActiveRecord. Provides location-based goodness for your Rails app. Requires the Geokit gem.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how can we access distance field?

hcyildirim opened this issue · comments

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

There is a patch in #56