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">
35 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
38 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
39 var zoom = <%= zoom %>;
41 <% if params['scale'] and params['scale'].length > 0 then %>
42 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
45 var map = createMap("map");
47 setMapCenter(centre, zoom);
50 marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>), null, "<%= t 'user.friend_map.your location' %>");
53 var near_icon = OpenLayers.Marker.defaultIcon();
54 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
55 var i = nearest.length;
57 var description = '<%= t 'user.friend_map.nearby mapper'%><a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a>'
58 var nearmarker = addMarkerToMap(new OpenLayers.LonLat(nearest[i].home_lon, nearest[i].home_lat), near_icon.clone(), description);
61 if (document.getElementById('updatehome')) {
62 map.events.register("click", map, setHome);
66 function setHome( e ) {
69 if (document.getElementById('updatehome').checked) {
70 var lonlat = getEventPosition(e);
72 document.getElementById('homerow').className = '';
73 document.getElementById('home_lat').value = lonlat.lat;
74 document.getElementById('home_lon').value = lonlat.lon;
77 removeMarkerFromMap(marker);
80 marker = addMarkerToMap(lonlat, null, "<%= t 'user.friend_map.your location' %>");