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