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">
23 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
26 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
27 <% if params[:scale].to_f > 0 then -%>
28 var zoom = <%= scale_to_zoom params[:scale] %>;
30 var zoom = <%= zoom %>;
33 var map = createMap("map");
35 setMapCenter(centre, zoom);
38 marker = addMarkerToMap(
39 new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)
40 <% if not setting_location %>
41 , null, '<%=escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
46 <% if setting_location %>
47 map.events.register("click", map, setHome);
50 <% if show_other_users %>
51 <% friends = @user.friends.collect { |f| f.befriendee }.select { |f| !f.home_lat.nil? and !f.home_lon.nil? } %>
52 <% nearest = @user.nearby - friends %>
54 var near_icon = OpenLayers.Marker.defaultIcon();
55 near_icon.url = OpenLayers.Util.getImageLocation("marker-green.png");
56 <% nearest.each do |u| %>
57 addMarkerToMap(new OpenLayers.LonLat(
58 <%= u.home_lon %>, <%= u.home_lat %>), near_icon.clone(),
59 '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "nearby mapper" })) %>'
63 var friend_icon = OpenLayers.Marker.defaultIcon();
64 friend_icon.url = OpenLayers.Util.getImageLocation("marker-blue.png");
65 <% friends.each do |u| %>
66 addMarkerToMap(new OpenLayers.LonLat(
67 <%= u.home_lon %>, <%= u.home_lat %>), friend_icon.clone(),
68 '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "friend" })) %>'
74 <% if setting_location %>
75 function setHome( e ) {
78 if (document.getElementById('updatehome').checked) {
79 var lonlat = getEventPosition(e);
81 document.getElementById('homerow').className = '';
82 document.getElementById('home_lat').value = lonlat.lat;
83 document.getElementById('home_lon').value = lonlat.lon;
86 removeMarkerFromMap(marker);
89 marker = addMarkerToMap(lonlat);