]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/index.rhtml
Disable the data browswer when the database is not available.
[rails.git] / app / views / site / index.rhtml
index a79ea10c39f867705bac09a1365f2dec46c7d259..2cca4d5292317b8a3728e94ed33e3ec6e057312a 100644 (file)
@@ -94,6 +94,12 @@ by the OpenStreetMap project and its contributors.
   function mapInit(){
     map = createMap("map");
 
+    <% unless OSM_STATUS == :api_offline or OSM_STATUS == :database_offline %>
+    map.dataLayer = new OpenLayers.Layer("Data", { "visibility": false });
+    map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData);
+    map.addLayer(map.dataLayer);
+    <% end %>
+
     <% if bbox %>
     var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
 
@@ -126,6 +132,14 @@ by the OpenStreetMap project and its contributors.
     handleResize();
   }
 
+  function toggleData() {
+    if (map.dataLayer.visibility) {
+      <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
+    } else {
+      closeSidebar();
+    }
+  }
+
   function getPosition() {
     return getMapCenter();
   }