-<script type="text/javascript">
- var nearest = [], friends = [];
- <% friends = @user.friends.collect { |f| f.befriendee } %>
- <% friends.each do |friend| %>
- <% if !friend.home_lat.nil? and !friend.home_lon.nil? %>
- friends.push({
- display_name : "<%= escape_javascript(friend.display_name) %>",
- home_lat : <%= friend.home_lat %>,
- home_lon : <%= friend.home_lon %>
- });
- <% end %>
- <% end %>
- <% nearest = @user.nearby - friends %>
- <% nearest.each do |nearby| %>
- nearest.push({
- display_name : "<%= escape_javascript(nearby.display_name) %>",
- home_lat : <%= nearby.home_lat %>,
- home_lon : <%= nearby.home_lon %>
- });
- <% end %>
-</script>
-
-<% if @user.home_lat.nil? or @user.home_lon.nil? %>
- <% lon = h(params['lon'] || '-0.1') %>
- <% lat = h(params['lat'] || '51.5') %>
- <% zoom = h(params['zoom'] || '4') %>
-<% 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' %>
+<%
+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.js' %>
<%= javascript_include_tag 'map.js' %>
<script type="text/javascript">
setMapCenter(centre, zoom);
<% if marker %>
- marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>), null, "<%= t 'user.map.your location' %>");
+ marker = addMarkerToMap(
+ new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)
+ <% if not setting_location %>
+ , null, '<%=escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
+ <% end %>
+ );
+ <% end %>
+
+ <% if setting_location %>
+ 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.getImageLocation("marker-green.png");
+ <% nearest.each do |u| %>
+ addMarkerToMap(new OpenLayers.LonLat(
+ <%= u.home_lon %>, <%= u.home_lat %>), near_icon.clone(),
+ '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "nearby mapper" })) %>'
+ );
+ <% end %>
+
+ var friend_icon = OpenLayers.Marker.defaultIcon();
+ friend_icon.url = OpenLayers.Util.getImageLocation("marker-blue.png");
+ <% friends.each do |u| %>
+ addMarkerToMap(new OpenLayers.LonLat(
+ <%= u.home_lon %>, <%= u.home_lat %>), friend_icon.clone(),
+ '<%= escape_javascript(render(:partial => "popup", :object => u, :locals => { :type => "friend" })) %>'
+ );
+ <% end %>
<% end %>
-
- var near_icon = OpenLayers.Marker.defaultIcon();
- near_icon.url = OpenLayers.Util.getImagesLocation() + "marker-green.png";;
- var i = nearest.length;
- while( i-- ) {
- var description = i18n('<%= t 'user.map.nearby mapper'%>', { nearby_user: '<a href="/user/'+nearest[i].display_name+'">'+nearest[i].display_name+'</a>' });
- var nearmarker = addMarkerToMap(new OpenLayers.LonLat(nearest[i].home_lon, nearest[i].home_lat), near_icon.clone(), description);
- }
-
- var friend_icon = OpenLayers.Marker.defaultIcon();
- friend_icon.url = OpenLayers.Util.getImagesLocation() + "marker-blue.png";;
- var i = friends.length;
- while( i-- ) {
- var description = i18n('<%= t 'user.map.friend'%>', { friend_user: '<a href="/user/'+friends[i].display_name+'">'+friends[i].display_name+'</a>' });
- var friendmarker = addMarkerToMap(new OpenLayers.LonLat(friends[i].home_lon, friends[i].home_lat), friend_icon.clone(), description);
- }
-
- if (document.getElementById('updatehome')) {
- map.events.register("click", map, setHome);
- }
}
+ <% if setting_location %>
function setHome( e ) {
closeMapPopup();
removeMarkerFromMap(marker);
}
- marker = addMarkerToMap(lonlat, null, "<%= t 'user.map.your location' %>");
+ marker = addMarkerToMap(lonlat);
}
}
+ <% end %>
window.onload = init;
// -->
</script>
-
-