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 <%= javascript_include_tag 'map.js' %>
18 <script type="text/javascript">
23 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
24 <% if params[:scale].to_f > 0 then -%>
25 var zoom = <%= scale_to_zoom params[:scale] %>;
27 var zoom = <%= zoom %>;
30 var map = createMap("map");
32 setMapCenter(centre, zoom);
35 marker = addMarkerToMap(
36 new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)
37 <% if not setting_location %>
38 , null, '<%=escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
43 <% if setting_location %>
44 map.events.register("click", map, setHome);
47 <% if show_other_users %>
48 <% friends = @user.friends.collect { |f| f.befriendee }.select { |f| !f.home_lat.nil? and !f.home_lon.nil? } %>
49 <% nearest = @user.nearby - friends %>
51 var near_icon = OpenLayers.Marker.defaultIcon();
52 near_icon.url = OpenLayers.Util.getImageLocation("marker-green.png");
53 <% nearest.each do |u| %>
54 addMarkerToMap(new OpenLayers.LonLat(
55 <%= u.home_lon %>, <%= u.home_lat %>), near_icon.clone(),
56 '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "nearby mapper" })) %>'
60 var friend_icon = OpenLayers.Marker.defaultIcon();
61 friend_icon.url = OpenLayers.Util.getImageLocation("marker-blue.png");
62 <% friends.each do |u| %>
63 addMarkerToMap(new OpenLayers.LonLat(
64 <%= u.home_lon %>, <%= u.home_lat %>), friend_icon.clone(),
65 '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "friend" })) %>'
71 <% if setting_location %>
72 function setHome( e ) {
75 if (document.getElementById('updatehome').checked) {
76 var lonlat = getEventPosition(e);
78 document.getElementById('homerow').className = '';
79 document.getElementById('home_lat').value = lonlat.lat;
80 document.getElementById('home_lon').value = lonlat.lon;
83 removeMarkerFromMap(marker);
86 marker = addMarkerToMap(lonlat);