-<% friends = @user.friends.collect { |f| f.befriendee }.select { |f| !f.home_lat.nil? and !f.home_lon.nil? } %>
-<% nearest = @user.nearby - friends %>
-
-<% if @user.home_lat.nil? or @user.home_lon.nil? %>
- <% lon = h(params['lon'] || '0') %>
- <% lat = h(params['lat'] || '20') %>
- <% zoom = h(params['zoom'] || '1') %>
-<% else %>
- <% marker = true %>
- <% mlon = @user.home_lon %>
- <% mlat = @user.home_lat %>
- <% lon = @user.home_lon %>
- <% lat = @user.home_lat %>
- <% zoom = '12' %>
-<% end %>
+<%
+if @user.home_lat.nil? or @user.home_lon.nil?
+ lon = h(params['lon'] || '0')
+ lat = h(params['lat'] || '20')
+ zoom = h(params['zoom'] || '1')
+else
+ marker = true
+ mlon = @user.home_lon
+ mlat = @user.home_lat
+ lon = @user.home_lon
+ lat = @user.home_lat
+ zoom = '12'
+end
+%>
<%= javascript_include_tag '/openlayers/OpenLayers.js' %>
<%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
setMapCenter(centre, zoom);
- <% if marker %>
+ <%
+ if marker :
+ %>
marker = addMarkerToMap(
- new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>), null,
- '<%= escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
+ new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)
+ <% if not setting_location : %>
+ , null, '<%=escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
+ <% end %>
);
- <% end %>
-
+ <%
+ end #endif
+
+ if setting_location :
+ # We're setting a location. Register for click events during init
+ %> map.events.register("click", map, setHome); <%
+ end
+
+ if show_other_users :
+ friends = @user.friends.collect { |f| f.befriendee }.select { |f| !f.home_lat.nil? and !f.home_lon.nil? }
+ nearest = @user.nearby - friends
+ %>
var near_icon = OpenLayers.Marker.defaultIcon();
near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";
<% nearest.each do |u| %>
<%= u.home_lon %>, <%= u.home_lat %>), near_icon.clone(),
'<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "nearby mapper" })) %>'
);
- <% end %>
+ <% end #next nearby user %>
var friend_icon = OpenLayers.Marker.defaultIcon();
friend_icon.url = OpenLayers.Util.getImagesLocation() + "marker-blue.png";
<%= u.home_lon %>, <%= u.home_lat %>), friend_icon.clone(),
'<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "friend" })) %>'
);
- <% end %>
+ <%
+ end #next friend
+ end #endif
+ %>
- if (document.getElementById('updatehome')) {
- map.events.register("click", map, setHome);
- }
}
+ <% if setting_location : %>
function setHome( e ) {
closeMapPopup();
removeMarkerFromMap(marker);
}
- marker = addMarkerToMap(
- lonlat, null,
- '<%= escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
- );
+ marker = addMarkerToMap(lonlat);
}
}
+
+ <% end %>
window.onload = init;
// -->
<tr id="homerow" <% unless @user.home_lat and @user.home_lon %> class="nohome" <%end%> >
<td class="fieldName"><%= t 'user.account.home location' %></td>
- <td><em class="message"><%= t 'user.account.no home location' %></em><span class="location"><%= t 'user.account.latitude' %> <%= f.text_field :home_lat, :size => 20, :id => "home_lat" %><%= t 'user.account.longitude' %><%= f.text_field :home_lon, :size => 20, :id => "home_lon" %></span></td>
+ <td><em class="message"><%= t 'user.account.no home location' %></em><span class="location"><%= t 'user.account.latitude' %> <%= f.text_field :home_lat, :size => 20, :id => "home_lat" %> <%= t 'user.account.longitude' %><%= f.text_field :home_lon, :size => 20, :id => "home_lon" %></span></td>
</tr>
<tr>
</table>
<% end %>
-<%= render :partial => 'map' %>
+<%= render :partial => 'map', :locals => { :setting_location => true, :show_other_users => false } %>
<% unless @user.data_public? %>
<a name="public"></a>