2 <% if !@user.home_lat.nil? and !@user.home_lon.nil? %>
3 <% if !@user.nearby.empty? %>
4 <% @user.nearby.each do |nearby| %>
5 <% nearest_str += "nearest.push( { 'display_name' : '#{nearby.display_name}', 'home_lat' : #{nearby.home_lat}, 'home_lon' : #{nearby.home_lon} } );\n" %>
9 <script type="text/javascript">
10 var nearest = [], friends = [];
14 <% if @user.home_lat.nil? or @user.home_lon.nil? %>
15 <% lon = h(params['lon'] || '-0.1') %>
16 <% lat = h(params['lat'] || '51.5') %>
17 <% zoom = h(params['zoom'] || '4') %>
20 <% mlon = @user.home_lon %>
21 <% mlat = @user.home_lat %>
22 <% lon = @user.home_lon %>
23 <% lat = @user.home_lat %>
27 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
28 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
29 <%= javascript_include_tag 'map.js' %>
31 <script type="text/javascript">
36 var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
37 var zoom = <%= zoom %>;
39 <% if params['scale'] and params['scale'].length > 0 then %>
40 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
43 var map = createMap("map");
45 map.setCenter(centre, zoom);
48 marker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)), null, "Your location");
51 var near_icon = OpenLayers.Marker.defaultIcon();
52 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
53 var i = nearest.length;
55 var description = 'Nearby mapper: <a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a>'
56 var nearmarker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(nearest[i].home_lon, nearest[i].home_lat)), near_icon.clone(), description);
59 map.events.register("click", map, setHome);
62 function setHome( e ) {
65 if (document.getElementById('updatehome').checked) {
66 var merc = map.getLonLatFromViewPortPx(e.xy);
67 var lonlat = mercatorToLonLat(merc);
69 document.getElementById('homerow').className = '';
70 document.getElementById('home_lat').value = lonlat.lat;
71 document.getElementById('home_lon').value = lonlat.lon;
74 removeMarkerFromMap(marker);
77 marker = addMarkerToMap(merc, null, "Your location");