2 <%= error_messages_for 'user' %>
3 <% form_tag :controller => 'user', :action => 'account', :display_name => @user.display_name do %>
4 <table style="width : 100%">
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><td>Password</td><td><%= password_field('user', 'pass_crypt',{:value => '', :size => 50, :maxlength => 255}) %></td></tr>
9 <tr><td>Confirm Password</td><td><%= password_field('user', 'pass_crypt_confirmation',{:value => '', :size => 50, :maxlength => 255}) %></td></tr>
10 <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>
13 <p>Update home location when I click on the map? <input type="checkbox" value="1" <% unless @user.home_lat and @user.home_lon %> checked="checked" <% end %> id="updatehome" /> </p>
14 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px;">
15 <% # This now just used to detect the width/height required for the popup. %>
16 <p id="highlightinfo"></p>
20 <tr><td valign="top">Description</td><td><%= text_area :user, :description, :value => @user.description, :class => "editDescription" %></td></tr>
22 <%= submit_tag 'Save Changes' %>
25 <% nearest_str = "" %>
26 <% if @user.home_lat and @user.home_lon %>
27 <h2>Users in your area</h2>
29 <% if @user.nearby.empty? %>
30 There are no users who admit to mapping in your area. Better go out and spread the word about OSM!
33 <p>These users are mapping in your area:</p>
39 <% @user.nearby(1,1).each do |nearby| %>
40 <% nearest_str += "nearest.push( { 'display_name' : '#{nearby.display_name}', 'home_lat' : #{nearby.home_lat}, 'home_lon' : #{nearby.home_lon} } );\n" %>
43 <td><%= link_to nearby.display_name, :controller => 'user', :action => 'view', :display_name => nearby.display_name %></td>
44 <td><%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => nearby.id %></td>
52 <script type="text/javascript">
53 var nearest = [], friends = [];
57 <% if @user.home_lat and @user.home_lon %>
59 <% mlon = @user.home_lon %>
60 <% mlat = @user.home_lat %>
61 <% lon = @user.home_lon %>
62 <% lat = @user.home_lat %>
64 <script type="text/javascript">
65 var mlat = <%= mlat %>;
66 var mlon = <%= mlon %>;
69 <% lon = params['lon'] || '-0.1' %>
70 <% lat = params['lat'] || '51.5' %>
71 <% zoom = params['zoom'] || '4' %>
76 <script type="text/javascript">
79 var zoom = <%= zoom %>;
80 var PI = 3.14159265358979323846;
84 <% if params['scale'] and params['scale'].length > 0 then %>
85 zoom = Math.log(360.0/(( <% print params['scale'].to_f() %> ) * 512.0)) / Math.log(2.0);
88 lon = lon * 20037508.34 / 180;
89 lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);
90 lat = lat * 20037508.34 / 180;
92 mlon = mlon * 20037508.34 / 180;
93 mlat = Math.log(Math.tan( (90 + mlat) * PI / 360)) / (PI / 180);
94 mlat = mlat * 20037508.34 / 180;
98 <script type="text/javascript" src="/javascripts/OpenLayers.js"></script>
100 <script type="text/javascript">
102 var map, layer, markers, marker, popup;
104 function mercator2lonlat( merc ) {
105 var lon_deg = (merc.lon / 20037508.34) * 180;
106 var lat_deg = (merc.lat / 20037508.34) * 180;
107 var PI = 3.14159265358979323846;
108 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
109 return new OpenLayers.LonLat(lon_deg,lat_deg);
112 function lonlat2mercator( ll ) {
113 var lon = ll.lon * 20037508.34 / 180;
114 var lat = Math.log(Math.tan( (90 + ll.lat) * PI / 360)) / (PI / 180);
115 lat = lat * 20037508.34 / 180;
116 return new OpenLayers.LonLat(lon,lat);
121 OpenLayers.Util.onImageLoadError = function() {
122 this.src = "http://www.openstreetmap.org/javascripts/img/404.png";
124 map = new OpenLayers.Map( "map",
125 {maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxZoomLevel:18, maxResolution:156543, units:'meters', projection: "EPSG:41001"} );
126 layer = new OpenLayers.Layer.LikeGoogle( "Mapnik", "http://tile.openstreetmap.org/", {type:'png'} );
128 layer = new OpenLayers.Layer.LikeGoogle( "Osmarender", "http://dev.openstreetmap.org/~ojw/Tiles/tile.php/", {type:'png'} );
133 markers = new OpenLayers.Layer.Markers("markers");
134 map.addLayer(markers);
137 marker = new OpenLayers.Marker(new OpenLayers.LonLat(mlon,mlat));
138 marker.events.register("click", "marker", markerOnClick );
139 markers.addMarker(marker);
142 var near_icon = OpenLayers.Marker.defaultIcon();
143 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
144 var i = nearest.length;
146 var nearmarker = new OpenLayers.Marker( lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) ), near_icon.clone() );
147 markers.addMarker( nearmarker );
148 nearmarker.events.register("click", "nearmarker", makeMarkerFunction( i ) );
151 map.addControl(new OpenLayers.Control.LayerSwitcher());
152 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
154 map.events.register("click", map, setHome);
157 function makeMarkerFunction( i ) {
158 return function() { markerOnClick( i ); };
161 function markerOnClick( i ) {
163 if( typeof( i ) == 'number' ) {
164 html = '<p>Nearby mapper: <a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a></p>';
165 html += '<p style="text-align:right">(<a href="#" onclick="return closePopup();">close</a>)</p>';
166 position = lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) );
168 html = '<p>Your location (<a href="#" onclick="return closePopup()">close</a>)</p>';
169 position = new OpenLayers.LonLat(mlon,mlat);
171 var box = document.getElementById( 'highlightinfo' );
172 box.innerHTML = html;
174 popup = new OpenLayers.Popup.AnchoredBubble( 'popup', position, new OpenLayers.Size( box.offsetWidth, box.offsetHeight ), html, OpenLayers.Marker.defaultIcon(), true );
175 map.addPopup( popup );
178 function closePopup() {
180 map.removePopup( popup );
186 function setHome( e ) {
188 if( ! document.getElementById( 'updatehome' ).checked )
190 var lonlat = map.getLonLatFromViewPortPx(e.xy)
192 var lon_deg = (lonlat.lon / 20037508.34) * 180;
193 var lat_deg = (lonlat.lat / 20037508.34) * 180;
194 var PI = 3.14159265358979323846;
195 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
196 var homerow = document.getElementById( 'homerow' );
197 var home_lat = document.getElementById( 'home_lat' );
198 var home_lon = document.getElementById( 'home_lon' );
199 homerow.className = '';
200 home_lat.value = lat_deg;
201 home_lon.value = lon_deg;
203 markers.removeMarker(marker);
205 marker = new OpenLayers.Marker(lonlat);
206 markers.addMarker(marker);
208 window.onload = init;
213 <% if @user.data_public? %>
214 All your edits are public.
216 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.
218 <% form_tag :controller => 'user', :action => 'go_public' do %>
219 <%= submit_tag 'Make all my edits public, forever' %>