2 <%= error_messages_for 'user' %>
3 <%= start_form_tag :controller => 'user', :action => 'edit', :display_name => @user.display_name %>
5 <tr><td>Email</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>
9 <tr><td valign="top">Description</td><td><%= text_area :user, :description, :value => @user.description, :class => "editDescription" %></td></tr>
11 <%= submit_tag 'Save Changes' %>
14 <% nearest_str = "" %>
15 <% if @user.home_lat and @user.home_lon %>
16 <h2>Users in your area</h2>
18 <% if @user.nearby.empty? %>
19 There are no users who admit to mapping in your area. Better go out and spread the word about OSM!
22 <p>These users are mapping in your area:</p>
29 <% @user.nearby(1,1).each do |nearby| %>
30 <% nearest_str = "nearest.push( { 'display_name' : '#{nearby.display_name}', 'home_lat' : #{nearby.home_lat}, 'home_lon' : #{nearby.home_lon} } )" %>
33 <td><%= nearby.email %></td>
34 <td><%= nearby.display_name %></td>
35 <td><%= link_to 'send message', :controller => 'message', :action => 'new', :display_name => nearby.display_name %></td>
43 <script type="text/javascript">
44 var nearest = [], friends = [];
50 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px;">
51 <h3>Click on the map to (re)set your location</h3>
54 <% if @user.home_lat and @user.home_lon %>
56 <% mlon = @user.home_lon %>
57 <% mlat = @user.home_lat %>
58 <% lon = @user.home_lon %>
59 <% lat = @user.home_lat %>
61 <script type="text/javascript">
62 var mlat = <%= mlat %>;
63 var mlon = <%= mlon %>;
66 <% lon = params['lon'] || '-0.1' %>
67 <% lat = params['lat'] || '51.5' %>
68 <% zoom = params['zoom'] || '4' %>
73 <script type="text/javascript">
76 var zoom = <%= zoom %>;
77 var PI = 3.14159265358979323846;
81 <% if params['scale'] and params['scale'].length > 0 then %>
82 zoom = Math.log(360.0/(( <% print params['scale'].to_f() %> ) * 512.0)) / Math.log(2.0);
85 lon = lon * 20037508.34 / 180;
86 lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);
87 lat = lat * 20037508.34 / 180;
89 mlon = mlon * 20037508.34 / 180;
90 mlat = Math.log(Math.tan( (90 + mlat) * PI / 360)) / (PI / 180);
91 mlat = mlat * 20037508.34 / 180;
95 <script type="text/javascript" src="/javascripts/OpenLayers.js"></script>
97 <script type="text/javascript">
99 var map, layer, markers, marker;
102 function mercator2lonlat( merc ) {
103 var lon_deg = (merc.lon / 20037508.34) * 180;
104 var lat_deg = (merc.lat / 20037508.34) * 180;
105 var PI = 3.14159265358979323846;
106 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
107 return new OpenLayers.LonLat(lon_deg,lat_deg);
110 function lonlat2mercator( ll ) {
111 var lon = ll.lon * 20037508.34 / 180;
112 var lat = Math.log(Math.tan( (90 + ll.lat) * PI / 360)) / (PI / 180);
113 lat = lat * 20037508.34 / 180;
114 return new OpenLayers.LonLat(lon,lat);
119 OpenLayers.Util.onImageLoadError = function() {
120 this.src = "http://www.openstreetmap.org/javascript/img/404.png";
122 map = new OpenLayers.Map( "map",
123 {maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxZoomLevel:18, maxResolution:156543, units:'meters', projection: "EPSG:41001"} );
124 layer = new OpenLayers.Layer.LikeGoogle( "Mapnik", "http://tile.openstreetmap.org/", {type:'png'} );
126 layer = new OpenLayers.Layer.LikeGoogle( "Osmarender", "http://dev.openstreetmap.org/~ojw/Tiles/tile.php/", {type:'png'} );
131 markers = new OpenLayers.Layer.Markers("markers");
132 map.addLayer(markers);
135 marker = new OpenLayers.Marker(new OpenLayers.LonLat(mlon,mlat));
136 markers.addMarker(marker);
139 var near_icon = OpenLayers.Marker.defaultIcon();
140 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
141 var i = nearest.length;
143 markers.addMarker( new OpenLayers.Marker( lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) ), near_icon ) );
146 map.addControl(new OpenLayers.Control.LayerSwitcher());
147 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
149 map.events.register("click", map, setHome);
152 function setHome( e ) {
153 var lonlat = map.getLonLatFromViewPortPx(e.xy)
155 var lon_deg = (lonlat.lon / 20037508.34) * 180;
156 var lat_deg = (lonlat.lat / 20037508.34) * 180;
157 var PI = 3.14159265358979323846;
158 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
159 var homerow = document.getElementById( 'homerow' );
160 var home_lat = document.getElementById( 'home_lat' );
161 var home_lon = document.getElementById( 'home_lon' );
162 homerow.className = '';
163 home_lat.value = lat_deg;
164 home_lon.value = lon_deg;
166 markers.removeMarker(marker);
168 marker = new OpenLayers.Marker(lonlat);
169 markers.addMarker(marker);
171 window.onload = init;
176 <% if @user.data_public? %>
177 All your edits are public.
179 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.
181 <%= start_form_tag :controller => 'user', :action => 'go_public'%>
182 <%= submit_tag 'Make all my edits public, forever' %>