From: Tom Hughes Date: Sun, 22 Jun 2008 12:23:43 +0000 (+0000) Subject: Merge 7922:8377 from trunk. X-Git-Tag: live~7743^2~5 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/960d13488a875245570ee498ee9a1ed7cac37bbe?hp=-c Merge 7922:8377 from trunk. --- 960d13488a875245570ee498ee9a1ed7cac37bbe diff --combined app/views/site/index.rhtml index 656db99c8,a79ea10c3..482ed85b8 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@@ -58,8 -58,8 +58,8 @@@ by the OpenStreetMap project and its co <% lat = h(params['mlat']) %> <% zoom = h(params['zoom'] || '12') %> <% layers = h(params['layers']) %> - <% elsif cookies.key?("location") %> - <% lon,lat,zoom,layers = cookies["location"].split(",") %> + <% elsif cookies.key?("_osm_location") %> + <% lon,lat,zoom,layers = cookies["_osm_location"].split("|") %> <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %> <% lon = @user.home_lon %> <% lat = @user.home_lat %> @@@ -76,8 -76,8 +76,8 @@@ <% lon = '-0.1' %> <% lat = '51.5' %> <% zoom = h(params['zoom'] || '5') %> - <% layers = h(params['layers']) %> <% end %> + <% layers = h(params['layers']) %> <% end %> <%= javascript_include_tag '/openlayers/OpenLayers.js' %> @@@ -94,10 -94,6 +94,10 @@@ function mapInit(){ map = createMap("map"); + map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false }); + map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData); + map.addLayer(map.dataLayer); + <% if bbox %> var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>); @@@ -113,7 -109,7 +113,7 @@@ setMapCenter(centre, zoom); <% end %> - <% if layers %> + <% if !layers.nil? and !layers.empty? %> setMapLayers("<%= layers %>"); <% end %> @@@ -130,14 -126,6 +130,14 @@@ handleResize(); } + function toggleData() { + if (map.dataLayer.visibility) { + <%= remote_function :url => { :controller => 'browse', :action => 'start' } %> + } else { + closeSidebar(); + } + } + function getPosition() { return getMapCenter(); } @@@ -160,7 -148,7 +160,7 @@@ updatelinks(lonlat.lon, lonlat.lat, zoom, layers); - document.cookie = "location=" + lonlat.lon + "," + lonlat.lat + "," + zoom + "," + layers; + document.cookie = "_osm_location=" + lonlat.lon + "|" + lonlat.lat + "|" + zoom + "|" + layers; } function resizeContent() { diff --combined config/routes.rb index c23509372,290ad6e08..52636b385 --- a/config/routes.rb +++ b/config/routes.rb @@@ -57,16 -57,6 +57,16 @@@ ActionController::Routing::Routes.draw map.connect "api/#{API_VERSION}/amf", :controller =>'amf', :action =>'talk' map.connect "api/#{API_VERSION}/swf/trackpoints", :controller =>'swf', :action =>'trackpoints' + # Data browsing + map.connect '/browse/start', :controller => 'browse', :action => 'start' + map.connect '/browse', :controller => 'browse', :action => 'index' + map.connect '/browse/way/:id', :controller => 'browse', :action => 'way', :id => /\d+/ + map.connect '/browse/way/:id/history', :controller => 'browse', :action => 'way_history', :id => /\d+/ + map.connect '/browse/node/:id', :controller => 'browse', :action => 'node', :id => /\d+/ + map.connect '/browse/node/:id/history', :controller => 'browse', :action => 'node_history', :id => /\d+/ + map.connect '/browse/relation/:id', :controller => 'browse', :action => 'relation', :id => /\d+/ + map.connect '/browse/relation/:id/history', :controller => 'browse', :action => 'relation_history', :id => /\d+/ + # web site map.connect '/', :controller => 'site', :action => 'index' @@@ -74,6 -64,7 +74,7 @@@ map.connect '/export', :controller => 'site', :action => 'export' map.connect '/login', :controller => 'user', :action => 'login' map.connect '/logout', :controller => 'user', :action => 'logout' + map.connect '/offline', :controller => 'site', :action => 'offline' map.connect '/user/new', :controller => 'user', :action => 'new' map.connect '/user/save', :controller => 'user', :action => 'save' map.connect '/user/confirm', :controller => 'user', :action => 'confirm' diff --combined public/javascripts/map.js index 2bdba6229,9f9be0987..291fd18fa --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@@ -7,11 -7,9 +7,11 @@@ OpenLayers._getScriptLocation = functio return "/openlayers/"; } -function createMap(divName) { +function createMap(divName, options) { + options = options || {}; + map = new OpenLayers.Map(divName, { - controls: [ + controls: options.controls || [ new OpenLayers.Control.ArgParser(), new OpenLayers.Control.Attribution(), new OpenLayers.Control.LayerSwitcher(), @@@ -20,7 -18,7 +20,7 @@@ new OpenLayers.Control.ScaleLine() ], units: "m", - maxResolution: 156543, + maxResolution: 156543.0339, numZoomLevels: 20 }); @@@ -157,7 -155,11 +157,11 @@@ function setMapLayers(layerConfig) for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) { var c = layerConfig.charAt(l++); - layers[i].setVisibility(c == "T"); + if (c == "T") { + layers[i].setVisibility(true); + } else if(c == "F") { + layers[i].setVisibility(false); + } } }