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>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><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>
11 <tr><td valign="top">Description</td><td><%= text_area :user, :description, :value => @user.description, :class => "editDescription" %></td></tr>
13 <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>
16 <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>
17 <div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 300px;">
18 <% # This now just used to detect the width/height required for the popup. %>
19 <p id="highlightinfo"></p>
23 <%= submit_tag 'Save Changes' %>
26 <% nearest_str = "" %>
27 <% if @user.home_lat and @user.home_lon %>
28 <% if !@user.nearby.empty? %>
29 <% @user.nearby.each do |nearby| %>
30 <% nearest_str += "nearest.push( { 'display_name' : '#{nearby.display_name}', 'home_lat' : #{nearby.home_lat}, 'home_lon' : #{nearby.home_lon} } );\n" %>
34 <script type="text/javascript">
35 var nearest = [], friends = [];
39 <% if @user.home_lat and @user.home_lon %>
41 <% mlon = @user.home_lon %>
42 <% mlat = @user.home_lat %>
43 <% lon = @user.home_lon %>
44 <% lat = @user.home_lat %>
46 <script type="text/javascript">
47 var mlat = <%= mlat %>;
48 var mlon = <%= mlon %>;
51 <% lon = params['lon'] || '-0.1' %>
52 <% lat = params['lat'] || '51.5' %>
53 <% zoom = params['zoom'] || '4' %>
58 <script type="text/javascript">
61 var zoom = <%= zoom %>;
62 var PI = 3.14159265358979323846;
66 <% if params['scale'] and params['scale'].length > 0 then %>
67 zoom = Math.log(360.0/(( <% print params['scale'].to_f() %> ) * 512.0)) / Math.log(2.0);
70 lon = lon * 20037508.34 / 180;
71 lat = Math.log(Math.tan( (90 + lat) * PI / 360)) / (PI / 180);
72 lat = lat * 20037508.34 / 180;
74 mlon = mlon * 20037508.34 / 180;
75 mlat = Math.log(Math.tan( (90 + mlat) * PI / 360)) / (PI / 180);
76 mlat = mlat * 20037508.34 / 180;
80 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
82 <script type="text/javascript">
84 var map, layer, markers, marker, popup;
86 function mercator2lonlat( merc ) {
87 var lon_deg = (merc.lon / 20037508.34) * 180;
88 var lat_deg = (merc.lat / 20037508.34) * 180;
89 var PI = 3.14159265358979323846;
90 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
91 return new OpenLayers.LonLat(lon_deg,lat_deg);
94 function lonlat2mercator( ll ) {
95 var lon = ll.lon * 20037508.34 / 180;
96 var lat = Math.log(Math.tan( (90 + ll.lat) * PI / 360)) / (PI / 180);
97 lat = lat * 20037508.34 / 180;
98 return new OpenLayers.LonLat(lon,lat);
103 OpenLayers.Util.onImageLoadError = function() {
104 this.src = OpenLayers.Util.getImagesLocation() + "404.png";
106 map = new OpenLayers.Map( "map",
107 {maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxZoomLevel:18, maxResolution:156543, units:'m', projection: "EPSG:41001"} );
108 layer = new OpenLayers.Layer.TMS( "Mapnik", "http://tile.openstreetmap.org/", {type:'png', getURL:getTileURL} );
110 layer = new OpenLayers.Layer.TMS( "Osmarender", "http://dev.openstreetmap.org/~ojw/Tiles/tile.php/", {type:'png', getURL:getTileURL} );
115 markers = new OpenLayers.Layer.Markers("markers");
116 map.addLayer(markers);
119 marker = new OpenLayers.Marker(new OpenLayers.LonLat(mlon,mlat));
120 marker.events.register("click", "marker", markerOnClick );
121 markers.addMarker(marker);
124 var near_icon = OpenLayers.Marker.defaultIcon();
125 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
126 var i = nearest.length;
128 var nearmarker = new OpenLayers.Marker( lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) ), near_icon.clone() );
129 markers.addMarker( nearmarker );
130 nearmarker.events.register("click", "nearmarker", makeMarkerFunction( i ) );
133 map.addControl(new OpenLayers.Control.LayerSwitcher());
134 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
136 map.events.register("click", map, setHome);
139 function getTileURL( bounds ) {
140 var res = this.map.getResolution();
141 var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
142 var y = Math.round ((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
143 var z = this.map.getZoom();
144 return this.url + z + "/" + x + "/" + y + "." + this.type;
147 function makeMarkerFunction( i ) {
148 return function() { markerOnClick( i ); };
151 function markerOnClick( i ) {
153 if( typeof( i ) == 'number' ) {
154 html = '<p>Nearby mapper: <a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a></p>';
155 html += '<p style="text-align:right">(<a href="#" onclick="return closePopup();">close</a>)</p>';
156 position = lonlat2mercator( new OpenLayers.LonLat( nearest[i].home_lon, nearest[i].home_lat ) );
158 html = '<p>Your location (<a href="#" onclick="return closePopup()">close</a>)</p>';
159 position = new OpenLayers.LonLat(mlon,mlat);
161 var box = document.getElementById( 'highlightinfo' );
162 box.innerHTML = html;
164 popup = new OpenLayers.Popup.AnchoredBubble( 'popup', position, new OpenLayers.Size( box.offsetWidth, box.offsetHeight ), html, OpenLayers.Marker.defaultIcon(), true );
165 map.addPopup( popup );
168 function closePopup() {
170 map.removePopup( popup );
176 function setHome( e ) {
178 if( ! document.getElementById( 'updatehome' ).checked )
180 var lonlat = map.getLonLatFromViewPortPx(e.xy)
182 var lon_deg = (lonlat.lon / 20037508.34) * 180;
183 var lat_deg = (lonlat.lat / 20037508.34) * 180;
184 var PI = 3.14159265358979323846;
185 lat_deg = 180/PI * (2 * Math.atan(Math.exp(lat_deg * PI / 180)) - PI / 2);
186 var homerow = document.getElementById( 'homerow' );
187 var home_lat = document.getElementById( 'home_lat' );
188 var home_lon = document.getElementById( 'home_lon' );
189 homerow.className = '';
190 home_lat.value = lat_deg;
191 home_lon.value = lon_deg;
193 markers.removeMarker(marker);
195 marker = new OpenLayers.Marker(lonlat);
196 markers.addMarker(marker);
198 window.onload = init;
203 <% if @user.data_public? %>
204 All your edits are public.
206 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.
208 <% form_tag :controller => 'user', :action => 'go_public' do %>
209 <%= submit_tag 'Make all my edits public, forever' %>