]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/index.rhtml
Use a cookie to remember the last location viewed on the slippy map.
[rails.git] / app / views / site / index.rhtml
index c182a924ddc3c94dd8a274013001b9f15439bcd1..aa808085f94af38170da2ae1b80abfaed0f6614c 100644 (file)
@@ -9,19 +9,21 @@
 <% if params['lon'] and params['lat'] %>
 <% lon =  params['lon'] %>
 <% lat =  params['lat'] %>
-<% zoom =  params['zoom'] || '4' %>
+<% zoom =  params['zoom'] || '5' %>
 <% elsif params['mlon'] and params['mlat'] %>
 <% lon = params['mlon'] %> 
 <% lat = params['mlat'] %>
 <% zoom =  params['zoom'] || '12' %>
-<% elsif @user %> 
+<% elsif cookies.key?("location") %>
+<% lon,lat,zoom = cookies["location"].value.first.split(",") %>
+<% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %> 
 <% lon =  @user.home_lon %>
 <% lat =  @user.home_lat %>
 <% zoom = '10' %>
 <% else %>
 <% lon =  '-0.1' %>
 <% lat =  '51.5' %>
-<% zoom =  params['zoom'] || '4' %>
+<% zoom =  params['zoom'] || '5' %>
 <% end %>
 
 <script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
@@ -73,6 +75,8 @@
     var zoom = map.getZoom();
 
     updatelinks(lonlat.lon, lonlat.lat, zoom);
+
+    document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom;
   }
 
   function getStyle( el, property ) {