From: John Firebaugh Date: Fri, 5 Oct 2012 19:59:03 +0000 (-0700) Subject: Simplify further by using OSM.home X-Git-Tag: live~5826 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/237d2ad60dd6b6778603ad274e2f6a168aada259 Simplify further by using OSM.home --- diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 384dba93f..77cb86a8d 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -1,14 +1,17 @@ $(document).ready(function () { - var params = $("#map").data(); var map = createMap("map"); - setMapCenter(new OpenLayers.LonLat(params.lon, params.lat), params.zoom); + if (OSM.home) { + setMapCenter(new OpenLayers.LonLat(OSM.home.lon, OSM.home.lat), 12); + } else { + setMapCenter(new OpenLayers.LonLat(0, 0), 0); + } if ($("#map").hasClass("set_location")) { var marker; - if (params.marker) { - marker = addMarkerToMap(new OpenLayers.LonLat(params.lon, params.lat)); + if (OSM.home) { + marker = addMarkerToMap(new OpenLayers.LonLat(OSM.home.lon, OSM.home.lat)); } map.events.register("click", map, function (e) { @@ -27,8 +30,6 @@ $(document).ready(function () { } }); } else { - addMarkerToMap(new OpenLayers.LonLat(params.lon, params.lat), null, params.marker.description); - $("[data-user]").each(function () { var user = $(this).data('user'); if (user.lon && user.lat) { diff --git a/app/views/user/account.html.erb b/app/views/user/account.html.erb index 80c8c0e49..6745f1b34 100644 --- a/app/views/user/account.html.erb +++ b/app/views/user/account.html.erb @@ -120,16 +120,7 @@ <% content_for :head do %> <%= javascript_include_tag "user" %> <% end %> - <% - home = @user.home_lat && @user.home_lon - data = { - :lon => @user.home_lon || 0, - :lat => @user.home_lat || 20, - :zoom => home ? 12 : 1, - :marker => !!home - } - %> - <%= content_tag "div", "", :id => "map", :class => "user_map set_location", :data => data %> + <%= content_tag "div", "", :id => "map", :class => "user_map set_location" %> diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index 04c78a900..e209f853a 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -113,16 +113,14 @@ <%= javascript_include_tag "user" %> <% end %> <% - data = { + user_data = { :lon => @user.home_lon, :lat => @user.home_lat, - :zoom => 12, - :marker => { - :description => render(:partial => "popup", :object => @user, :locals => {:type => "your location"}) - } + :icon => "marker.png", + :description => render(:partial => "popup", :object => @user, :locals => {:type => "your location"}) } %> - <%= content_tag "div", "", :id => "map", :class => "user_map", :data => data %> + <%= content_tag "div", "", :id => "map", :class => "user_map", :data => {:user => user_data} %> <% end %> <% friends = @this_user.friends.collect { |f| f.befriendee } %>