]> git.openstreetmap.org Git - rails.git/commitdiff
Merge 7922:8377 from trunk.
authorTom Hughes <tom@compton.nu>
Sun, 22 Jun 2008 12:23:43 +0000 (12:23 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 22 Jun 2008 12:23:43 +0000 (12:23 +0000)
1  2 
app/views/site/index.rhtml
config/routes.rb
public/javascripts/map.js

index 656db99c80008a3b8757d061bf25d12f52dad4d1,a79ea10c39f867705bac09a1365f2dec46c7d259..482ed85b89880744e8d556d5082c41a0f627889c
@@@ -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' %>
    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 %>);
  
      setMapCenter(centre, zoom);
      <% end %>
  
-     <% if layers %>
+     <% if !layers.nil? and !layers.empty? %>
      setMapLayers("<%= layers %>");
      <% end %>
  
      handleResize();
    }
  
 +  function toggleData() {
 +    if (map.dataLayer.visibility) {
 +      <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
 +    } else {
 +      closeSidebar();
 +    }
 +  }
 +
    function getPosition() {
      return getMapCenter();
    }
  
      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 c23509372c8a2c4c9ba761e433332729df242f43,290ad6e08d8623229de33769a5723a680c535945..52636b3859ec2e4b1dcbd71f61a923a717ffbb0e
@@@ -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'
index 2bdba6229b589b8d52ae3a96fd8e21e5d8b361d9,9f9be0987d4fa3d0071f0d5f8c55a465db16b452..291fd18fa29ff645520a1038b0dfa92e338d9bc6
@@@ -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);
+       }
     }
  }