]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/index.rhtml
Only add the data layer to the main map, and use the visibility changed
[rails.git] / app / views / site / index.rhtml
index fa31d848ba2f3ab39806270f5e63a1360c366cb5..bd114a6b36e54c640dc1221261de6ccec5f37e2a 100644 (file)
@@ -9,7 +9,6 @@
 <%= render :partial => 'search' %>
 
 <div id="map">
-<div id="datalink"><%= link_to_remote 'See Data', {:url => {:controller => 'browse', :action => 'start'}}, {:href => url_for( {:controller => 'browse', :action => 'index'}), :id => 'browseanchor', :title => 'browse data'} %></div>
 <div id="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
 </div> 
 
@@ -22,7 +21,7 @@
 <tr>
 <td colspan="2" align="center">
 Licensed under the Creative Commons Attribution-Share Alike 2.0 license
-by the OpenStreetMap project and it's contributors.
+by the OpenStreetMap project and its contributors.
 </td>
 </table>
 </div>
@@ -87,6 +86,10 @@ by the OpenStreetMap project and it's contributors.
   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 %>);
 
@@ -119,6 +122,14 @@ by the OpenStreetMap project and it's contributors.
     handleResize();
   }
 
+  function toggleData() {
+    if (map.dataLayer.visibility) {
+      <%= remote_function :url => { :controller => 'browse', :action => 'start' } %>
+    } else {
+      closeSidebar();
+    }
+  }
+
   function getPosition() {
     return getMapCenter();
   }