AR: Easy location (lat/long) handling + in_radius + find on a given map section
gem i has_a_location
Table with (see: MIGRATION):
lat
lng
Model:
User < ActiveRecord::Base
has_a_location default_location_lat: 10.10, default_location_lng: 20.20
end
user.location = [12.2332,323.2323]
[latitude,longitude]show_map if user.location
user.in_radius(500)
=> users in 500 miles distanceUser.on_map([11.12343,34,183323],[640,480],5)
=> all users visible on a 640x480 map zoom-level 5, with center 11.12343,34,183323user.surrounding_on_map([640,480],5)
=> other users visible on this mapLegend: options key => default [recommended]
default_location_lng: 0 [your default map longitude]
default_location_lat: 0 [your default map latitude]
default_units: :miles [:kms]
default_formula: :sphere [:flat]
lat_column_name: :lat [:location_latitude]
lng_column_name: :lng [:location_longitude]
distance_column_name: :distance [:distance]
Michael Grosser [email protected] License: MIT