1 <% friends = @user.friends.collect { |f| f.befriendee }.select { |f| !f.home_lat.nil? and !f.home_lon.nil? } %>
2 <% nearest = @user.nearby - friends %>
4 <% if @user.home_lat.nil? or @user.home_lon.nil? %>
5 <% lon = h(params['lon'] || '-0.1') %>
6 <% lat = h(params['lat'] || '51.5') %>
7 <% zoom = h(params['zoom'] || '4') %>
10 <% mlon = @user.home_lon %>
11 <% mlat = @user.home_lat %>
12 <% lon = @user.home_lon %>
13 <% lat = @user.home_lat %>
17 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
18 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
19 <%= javascript_include_tag 'map.js' %>
21 <script type="text/javascript">
25 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
28 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
29 var zoom = <%= zoom %>;
31 <% if params['scale'] and params['scale'].length > 0 then %>
32 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
35 var map = createMap("map");
37 setMapCenter(centre, zoom);
40 marker = addMarkerToMap(
41 new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>), null,
42 '<%= escape_javascript(render :partial => "popup", :object => @user, :locals => { :type => "your location" }) %>'
46 var near_icon = OpenLayers.Marker.defaultIcon();
47 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";
48 <% nearest.each do |u| %>
49 addMarkerToMap(new OpenLayers.LonLat(
50 <%= u.home_lon %>, <%= u.home_lat %>), near_icon.clone(),
51 '<%= escape_javascript(render :partial => "popup", :object => u, :locals => { :type => "nearby mapper" }) %>'
55 var friend_icon = OpenLayers.Marker.defaultIcon();
56 friend_icon.url = OpenLayers.Util.getImagesLocation() + "marker-blue.png";
57 <% friends.each do |u| %>
58 addMarkerToMap(new OpenLayers.LonLat(
59 <%= u.home_lon %>, <%= u.home_lat %>), friend_icon.clone(),
60 '<%= escape_javascript(render :partial => "popup", :object => u, :locals => { :type => "friend" }) %>'
64 if (document.getElementById('updatehome')) {
65 map.events.register("click", map, setHome);
69 function setHome( e ) {
72 if (document.getElementById('updatehome').checked) {
73 var lonlat = getEventPosition(e);
75 document.getElementById('homerow').className = '';
76 document.getElementById('home_lat').value = lonlat.lat;
77 document.getElementById('home_lon').value = lonlat.lon;
80 removeMarkerFromMap(marker);
83 marker = addMarkerToMap(
85 '<%= escape_javascript(render :partial => "popup", :object => @user, :locals => { :type => "your location" }) %>'