2 <%= error_messages_for 'user' %>
3 <%= start_form_tag :controller => 'user', :action => 'edit', :display_name => @user.display_name %>
5 <tr><td>Name</td><td><%= @user.email %></td></tr>
6 <tr><td>Mapper since</td><td><%= @user.creation_time %> (<%= time_ago_in_words(@user.creation_time) %> ago)</td></tr>
7 <tr><td>Display Name</td><td><%= text_field :user, :display_name, :value => @user.display_name %></td></tr>
8 <tr id="homerow" <% unless @user.home_lat and @user.home_lon %> class="nohome" <%end%> ><td>Your home</td><td><em class="message">You have not entered your home location.</em><span class="location">Latitude: <%= text_field :user, :home_lat, :value => @user.home_lat, :size => 20, :id => "home_lat" %> Longitude <%= text_field :user, :home_lon, :value => @user.home_lon, :size => 20, :id => "home_lon" %></span> </td></tr>
11 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px;">
12 <h3>Click on the map to (re)set your location</h3>
16 <tr><td valign="top">Description</td><td><%= text_area :user, :description, :value => @user.description, :class => "editDescription" %></td></tr>
18 <%= submit_tag 'Save Changes' %>
21 <% nearest_str = "" %>
22 <% if @user.home_lat and @user.home_lon %>
23 <h2>Users in your area</h2>
25 <% if @user.nearby.empty? %>
26 There are no users who admit to mapping in your area. Better go out and spread the word about OSM!
29 <p>These users are mapping in your area:</p>
35 <% @user.nearby(1,1).each do |nearby| %>
36 <% nearest_str = "nearest.push( { 'display_name' : '#{nearby.display_name}', 'home_lat' : #{nearby.home_lat}, 'home_lon' : #{nearby.home_lon} } )" %>
39 <td><%= link_to nearby.display_name, :controller => 'user', :action => 'view', :display_name => nearby.display_name %></td>
40 <td><%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => nearby.id %></td>
48 <script type="text/javascript">
49 var nearest = [], friends = [];
53 <% if @user.home_lat and @user.home_lon %>
55 <% mlon = @user.home_lon %>
56 <% mlat = @user.home_lat %>
57 <% lon = @user.home_lon %>
58 <% lat = @user.home_lat %>
60 <script type="text/javascript">
61 var mlat = <%= mlat %>;
62 var mlon = <%= mlon %>;
65 <% lon = params['lon'] || '-0.1' %>
66 <% lat = params['lat'] || '51.5' %>
67 <% zoom = params['zoom'] || '4' %>
72 <script type="text/javascript">
75 var zoom = <%= zoom %>;
76 var PI = 3.14159265358979323846;
80 <% if params['scale'] and params['scale'].length > 0 then %>
81 zoom = Math.log(360.0/(( <% print params['scale'].to_f() %> ) * 512.0)) / Math.log(2.0);
84 lon = lon * 20037508.34 / 180;
85 lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);
86 lat = lat * 20037508.34 / 180;
88 mlon = mlon * 20037508.34 / 180;
89 mlat = Math.log(Math.tan( (90 + mlat) * PI / 360)) / (PI / 180);
90 mlat = mlat * 20037508.34 / 180;
94 <script type="text/javascript" src="/javascripts/OpenLayers.js"></script>
96 <script type="text/javascript">
98 var map, layer, markers, marker;
101 function mercator2lonlat( merc ) {
102 var lon_deg = (merc.lon / 20037508.34) * 180;
103 var lat_deg = (merc.lat / 20037508.34) * 180;
104 var PI = 3.14159265358979323846;
105 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
106 return new OpenLayers.LonLat(lon_deg,lat_deg);
109 function lonlat2mercator( ll ) {
110 var lon = ll.lon * 20037508.34 / 180;
111 var lat = Math.log(Math.tan( (90 + ll.lat) * PI / 360)) / (PI / 180);
112 lat = lat * 20037508.34 / 180;
113 return new OpenLayers.LonLat(lon,lat);
118 OpenLayers.Util.onImageLoadError = function() {
119 this.src = "http://www.openstreetmap.org/javascripts/img/404.png";
121 map = new OpenLayers.Map( "map",
122 {maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxZoomLevel:18, maxResolution:156543, units:'meters', projection: "EPSG:41001"} );
123 layer = new OpenLayers.Layer.LikeGoogle( "Mapnik", "http://tile.openstreetmap.org/", {type:'png'} );
125 layer = new OpenLayers.Layer.LikeGoogle( "Osmarender", "http://dev.openstreetmap.org/~ojw/Tiles/tile.php/", {type:'png'} );
130 markers = new OpenLayers.Layer.Markers("markers");
131 map.addLayer(markers);
134 marker = new OpenLayers.Marker(new OpenLayers.LonLat(mlon,mlat));
135 markers.addMarker(marker);
138 var near_icon = OpenLayers.Marker.defaultIcon();
139 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
140 var i = nearest.length;
142 markers.addMarker( new OpenLayers.Marker( lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) ), near_icon ) );
145 map.addControl(new OpenLayers.Control.LayerSwitcher());
146 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
148 map.events.register("click", map, setHome);
151 function setHome( e ) {
152 var lonlat = map.getLonLatFromViewPortPx(e.xy)
154 var lon_deg = (lonlat.lon / 20037508.34) * 180;
155 var lat_deg = (lonlat.lat / 20037508.34) * 180;
156 var PI = 3.14159265358979323846;
157 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
158 var homerow = document.getElementById( 'homerow' );
159 var home_lat = document.getElementById( 'home_lat' );
160 var home_lon = document.getElementById( 'home_lon' );
161 homerow.className = '';
162 home_lat.value = lat_deg;
163 home_lon.value = lon_deg;
165 markers.removeMarker(marker);
167 marker = new OpenLayers.Marker(lonlat);
168 markers.addMarker(marker);
170 window.onload = init;
175 <% if @user.data_public? %>
176 All your edits are public.
178 Currently your edits are anonymous and people can't find out where you are located. To show what you edited and allow people to contact you through the website, click the button below. This action cannot be reversed.
180 <%= start_form_tag :controller => 'user', :action => 'go_public'%>
181 <%= submit_tag 'Make all my edits public, forever' %>