fixes http://trac.openstreetmap.org/ticket/3645 . Can now pass in show_other_users and setting_location to the map partial
This commit is contained in:
parent
cb6d6c2463
commit
41589b6ef9
3 changed files with 45 additions and 32 deletions
|
@ -1,18 +1,17 @@
|
|||
<% 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' %>
|
||||
|
@ -36,13 +35,27 @@
|
|||
|
||||
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| %>
|
||||
|
@ -50,7 +63,7 @@
|
|||
<%= 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";
|
||||
|
@ -59,13 +72,14 @@
|
|||
<%= 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();
|
||||
|
||||
|
@ -80,12 +94,11 @@
|
|||
removeMarkerFromMap(marker);
|
||||
}
|
||||
|
||||
marker = addMarkerToMap(
|
||||
lonlat, null,
|
||||
'<%= escape_javascript(render(:partial => "popup", :object => @user, :locals => { :type => "your location" })) %>'
|
||||
);
|
||||
marker = addMarkerToMap(lonlat);
|
||||
}
|
||||
}
|
||||
|
||||
<% end %>
|
||||
|
||||
window.onload = init;
|
||||
// -->
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
|
||||
<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>
|
||||
|
@ -119,7 +119,7 @@
|
|||
</table>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => 'map' %>
|
||||
<%= render :partial => 'map', :locals => { :setting_location => true, :show_other_users => false } %>
|
||||
|
||||
<% unless @user.data_public? %>
|
||||
<a name="public"></a>
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
<%= t 'user.view.if set location', :settings_link => (link_to t('user.view.settings_link_text'), :controller => 'user', :action => 'account', :display_name => @user.display_name) %>
|
||||
</p>
|
||||
<% else %>
|
||||
<%= render :partial => 'map' %>
|
||||
<%= render :partial => 'map', :locals => { :setting_location => false, :show_other_users => true } %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue