2 if @user.home_lat.nil? or @user.home_lon.nil?
3 lon = h(params['lon'] || '0')
4 lat = h(params['lat'] || '20')
5 zoom = h(params['zoom'] || '1')
16 <script type="text/javascript">
21 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
22 <% if params[:scale].to_f > 0 then -%>
23 var zoom = <%= scale_to_zoom params[:scale] %>;
25 var zoom = <%= zoom %>;
28 var map = createMap("map");
30 setMapCenter(centre, zoom);
33 marker = addMarkerToMap(
34 new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)
35 <% if not setting_location %>
36 , null, '<%=escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
41 <% if setting_location %>
42 map.events.register("click", map, setHome);
45 <% if show_other_users %>
46 <% friends = @user.friends.collect { |f| f.befriendee }.select { |f| !f.home_lat.nil? and !f.home_lon.nil? } %>
47 <% nearest = @user.nearby - friends %>
49 var near_icon = OpenLayers.Marker.defaultIcon();
50 near_icon.url = OpenLayers.Util.getImageLocation("marker-green.png");
51 <% nearest.each do |u| %>
52 addMarkerToMap(new OpenLayers.LonLat(
53 <%= u.home_lon %>, <%= u.home_lat %>), near_icon.clone(),
54 '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "nearby mapper" })) %>'
58 var friend_icon = OpenLayers.Marker.defaultIcon();
59 friend_icon.url = OpenLayers.Util.getImageLocation("marker-blue.png");
60 <% friends.each do |u| %>
61 addMarkerToMap(new OpenLayers.LonLat(
62 <%= u.home_lon %>, <%= u.home_lat %>), friend_icon.clone(),
63 '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "friend" })) %>'
69 <% if setting_location %>
70 function setHome( e ) {
73 if (document.getElementById('updatehome').checked) {
74 var lonlat = getEventPosition(e);
76 document.getElementById('homerow').className = '';
77 document.getElementById('home_lat').value = lonlat.lat;
78 document.getElementById('home_lon').value = lonlat.lon;
81 removeMarkerFromMap(marker);
84 marker = addMarkerToMap(lonlat);