2 <%= error_messages_for 'user' %>
3 <%= start_form_tag :controller => 'user', :action => 'edit', :display_name => @user.display_name %>
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 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 <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>
12 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px;">
13 <% # This now just used to detect the width/height required for the popup. %>
14 <p id="highlightinfo"></p>
18 <tr><td valign="top">Description</td><td><%= text_area :user, :description, :value => @user.description, :class => "editDescription" %></td></tr>
20 <%= submit_tag 'Save Changes' %>
23 <% nearest_str = "" %>
24 <% if @user.home_lat and @user.home_lon %>
25 <h2>Users in your area</h2>
27 <% if @user.nearby.empty? %>
28 There are no users who admit to mapping in your area. Better go out and spread the word about OSM!
31 <p>These users are mapping in your area:</p>
37 <% @user.nearby(1,1).each do |nearby| %>
38 <% nearest_str += "nearest.push( { 'display_name' : '#{nearby.display_name}', 'home_lat' : #{nearby.home_lat}, 'home_lon' : #{nearby.home_lon} } );\n" %>
41 <td><%= link_to nearby.display_name, :controller => 'user', :action => 'view', :display_name => nearby.display_name %></td>
42 <td><%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => nearby.id %></td>
50 <script type="text/javascript">
51 var nearest = [], friends = [];
55 <% if @user.home_lat and @user.home_lon %>
57 <% mlon = @user.home_lon %>
58 <% mlat = @user.home_lat %>
59 <% lon = @user.home_lon %>
60 <% lat = @user.home_lat %>
62 <script type="text/javascript">
63 var mlat = <%= mlat %>;
64 var mlon = <%= mlon %>;
67 <% lon = params['lon'] || '-0.1' %>
68 <% lat = params['lat'] || '51.5' %>
69 <% zoom = params['zoom'] || '4' %>
74 <script type="text/javascript">
77 var zoom = <%= zoom %>;
78 var PI = 3.14159265358979323846;
82 <% if params['scale'] and params['scale'].length > 0 then %>
83 zoom = Math.log(360.0/(( <% print params['scale'].to_f() %> ) * 512.0)) / Math.log(2.0);
86 lon = lon * 20037508.34 / 180;
87 lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);
88 lat = lat * 20037508.34 / 180;
90 mlon = mlon * 20037508.34 / 180;
91 mlat = Math.log(Math.tan( (90 + mlat) * PI / 360)) / (PI / 180);
92 mlat = mlat * 20037508.34 / 180;
96 <script type="text/javascript" src="/javascripts/OpenLayers.js"></script>
98 <script type="text/javascript">
100 var map, layer, markers, marker, popup;
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/javascripts/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 marker.events.register("click", "marker", markerOnClick );
137 markers.addMarker(marker);
140 var near_icon = OpenLayers.Marker.defaultIcon();
141 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
142 var i = nearest.length;
144 var nearmarker = new OpenLayers.Marker( lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) ), near_icon.clone() );
145 markers.addMarker( nearmarker );
146 nearmarker.events.register("click", "nearmarker", makeMarkerFunction( i ) );
149 map.addControl(new OpenLayers.Control.LayerSwitcher());
150 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
152 map.events.register("click", map, setHome);
155 function makeMarkerFunction( i ) {
156 return function() { markerOnClick( i ); };
159 function markerOnClick( i ) {
161 if( typeof( i ) == 'number' ) {
162 html = '<p>Nearby mapper: <a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a></p>';
163 html += '<p style="text-align:right">(<a href="#" onclick="return closePopup();">close</a>)</p>';
164 position = lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) );
166 html = '<p>Your location (<a href="#" onclick="return closePopup()">close</a>)</p>';
167 position = new OpenLayers.LonLat(mlon,mlat);
169 var box = document.getElementById( 'highlightinfo' );
170 box.innerHTML = html;
172 popup = new OpenLayers.Popup.AnchoredBubble( 'popup', position, new OpenLayers.Size( box.offsetWidth, box.offsetHeight ), html, OpenLayers.Marker.defaultIcon(), true );
173 map.addPopup( popup );
176 function closePopup() {
178 map.removePopup( popup );
184 function setHome( e ) {
186 if( ! document.getElementById( 'updatehome' ).checked )
188 var lonlat = map.getLonLatFromViewPortPx(e.xy)
190 var lon_deg = (lonlat.lon / 20037508.34) * 180;
191 var lat_deg = (lonlat.lat / 20037508.34) * 180;
192 var PI = 3.14159265358979323846;
193 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
194 var homerow = document.getElementById( 'homerow' );
195 var home_lat = document.getElementById( 'home_lat' );
196 var home_lon = document.getElementById( 'home_lon' );
197 homerow.className = '';
198 home_lat.value = lat_deg;
199 home_lon.value = lon_deg;
201 markers.removeMarker(marker);
203 marker = new OpenLayers.Marker(lonlat);
204 markers.addMarker(marker);
206 window.onload = init;
211 <% if @user.data_public? %>
212 All your edits are public.
214 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.
216 <%= start_form_tag :controller => 'user', :action => 'go_public'%>
217 <%= submit_tag 'Make all my edits public, forever' %>