X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/acd72861ed8ad46d759a6e509f3e7c459db1a4f5..3700b534e404a25ef5db1bb8283bae3cddb818fb:/app/views/user/_map.html.erb diff --git a/app/views/user/_map.html.erb b/app/views/user/_map.html.erb index 17f4ed344..6ab713995 100644 --- a/app/views/user/_map.html.erb +++ b/app/views/user/_map.html.erb @@ -1,37 +1,17 @@ - - -<% 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 %> +<% +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' %> @@ -56,30 +36,43 @@ 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.getImagesLocation() + "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.getImagesLocation() + "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: ''+nearest[i].display_name+'' }); - 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: ''+friends[i].display_name+'' }); - 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(); @@ -94,12 +87,11 @@ removeMarkerFromMap(marker); } - marker = addMarkerToMap(lonlat, null, "<%= t 'user.map.your location' %>"); + marker = addMarkerToMap(lonlat); } } + <% end %> window.onload = init; // --> - -