X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/10e13b8feacca7bdd04f335a5b7badc3e6ae8dba..9634ab8fc1a2bd8bfd3a6e9c83315d31c277861c:/app/views/site/index.rhtml diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index aa808085f..2a468f893 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -10,12 +10,14 @@ <% lon = params['lon'] %> <% lat = params['lat'] %> <% zoom = params['zoom'] || '5' %> +<% layers = params['layers'] %> <% elsif params['mlon'] and params['mlat'] %> <% lon = params['mlon'] %> <% lat = params['mlat'] %> <% zoom = params['zoom'] || '12' %> +<% layers = params['layers'] %> <% elsif cookies.key?("location") %> -<% lon,lat,zoom = cookies["location"].value.first.split(",") %> +<% lon,lat,zoom,layers = 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 %> @@ -24,6 +26,7 @@ <% lon = '-0.1' %> <% lat = '51.5' %> <% zoom = params['zoom'] || '5' %> +<% layers = params['layers'] %> <% end %> @@ -42,6 +45,7 @@ function init(){ var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>)); var zoom = <%= zoom %>; + var layers = "<%= layers %>"; <% if params['scale'] and params['scale'].length > 0 then %> zoom = scaleToZoom(<%= params['scale'].to_f() %>); @@ -53,6 +57,10 @@ addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>))); <% end %> + <% if layers %> + setMapLayers(layers); + <% end %> + map.events.register("moveend", map, updateLocation); updateLocation(); @@ -73,10 +81,11 @@ function updateLocation() { var lonlat = mercatorToLonLat(map.getCenter()); var zoom = map.getZoom(); + var layers = getMapLayers(); - updatelinks(lonlat.lon, lonlat.lat, zoom); + updatelinks(lonlat.lon, lonlat.lat, zoom, layers); - document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom; + document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers; } function getStyle( el, property ) {