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/OpenLayers.js' %>
17 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
18 <%= javascript_include_tag 'map.js' %>
20 <script type="text/javascript">
24 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
27 var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
28 var zoom = <%= zoom %>;
30 <% if params['scale'] and params['scale'].length > 0 then %>
31 zoom = scaleToZoom(<%= params['scale'].to_f() %>);
34 var map = createMap("map");
36 setMapCenter(centre, zoom);
39 marker = addMarkerToMap(
40 new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)
41 <% if not setting_location %>
42 , null, '<%=escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
47 <% if setting_location %>
48 map.events.register("click", map, setHome);
51 <% if show_other_users %>
52 <% friends = @user.friends.collect { |f| f.befriendee }.select { |f| !f.home_lat.nil? and !f.home_lon.nil? } %>
53 <% nearest = @user.nearby - friends %>
55 var near_icon = OpenLayers.Marker.defaultIcon();
56 near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";
57 <% nearest.each do |u| %>
58 addMarkerToMap(new OpenLayers.LonLat(
59 <%= u.home_lon %>, <%= u.home_lat %>), near_icon.clone(),
60 '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "nearby mapper" })) %>'
64 var friend_icon = OpenLayers.Marker.defaultIcon();
65 friend_icon.url = OpenLayers.Util.getImagesLocation() + "marker-blue.png";
66 <% friends.each do |u| %>
67 addMarkerToMap(new OpenLayers.LonLat(
68 <%= u.home_lon %>, <%= u.home_lat %>), friend_icon.clone(),
69 '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "friend" })) %>'
75 <% if setting_location %>
76 function setHome( e ) {
79 if (document.getElementById('updatehome').checked) {
80 var lonlat = getEventPosition(e);
82 document.getElementById('homerow').className = '';
83 document.getElementById('home_lat').value = lonlat.lat;
84 document.getElementById('home_lon').value = lonlat.lon;
87 removeMarkerFromMap(marker);
90 marker = addMarkerToMap(lonlat);