map view defaults to a home lat and lon

This commit is contained in:
Nick Black 2007-04-30 09:57:54 +00:00
parent f4e4fefaa1
commit 8bd09c0828
6 changed files with 52 additions and 3 deletions

View file

@ -3,6 +3,13 @@ class ApiController < ApplicationController
before_filter :authorize
after_filter :compress_output
helper :user
model :user
def authorize_web
@current_user = User.find_by_token(session[:token])
end
# The maximum area you're allowed to request, in square degrees
MAX_REQUEST_AREA = 0.25

View file

@ -162,7 +162,16 @@ class UserController < ApplicationController
def diary
@this_user = User.find_by_display_name(params[:display_name])
end
def contact_others(user_id, message_body)
@to = User.find_by_id(user_id)
@to.messages.new = body
if @to.save
flash[:notice] = Message sent
end
#Send a message to other users - maybe there's a rails messaging plugin
end
end

View file

@ -58,7 +58,10 @@ class User < ActiveRecord::Base
return el1
end
def get_nearby_users
def nearby(lat_range=1, lon_range=1)
nearby = User.find(:all, :conditions => "#{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and #{self.home_lon} > home_lon - #{lon_range} and #{self.home_lon} < home_lon + #{lon_range} and data_public = 1")
return nearby
end

View file

@ -20,9 +20,15 @@ eg:Essen
</div>
</div>
<% if @user and params['lon'].nil? and params['lat'].nil? %>
<% lon = @user.home_lon %>
<% lat = @user.home_lat %>
<% zoom = '10' %>
<%else%>
<% lon = params['lon'] || '-0.1' %>
<% lat = params['lat'] || '51.5' %>
<% zoom = params['zoom'] || '4' %>
<% end %>
<script type="text/javascript">
var lon = <%= lon %>;

View file

@ -10,9 +10,30 @@
<h2>Users in your area</h2>
These users are mapping in your area:
<% if @user.nearby.empty? %>
There are no users mapping in your area. Better go out and spread the word about OSM!
<% else %>
<p>These users are mapping in your area:</p>
<table>
<tr>
<th>Email</th>
<th>Name</th>
<th>Contact</th>
</tr>
<% @user.nearby(1,1).each do |nearby| %>
<tr>
<td><%= nearby.email %></td>
<td><%= nearby.display_name %></td>
<td>FIXME: send user an email</td>
</tr>
<%end%>
</table>
<%end%>
<br />
FIXME: OL Map showing the users on
<h2>Privacy</h2>
<% if @user.data_public? %>