]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/index.rhtml
Showing a nice message for browsers with javascript disabled. closes #36
[rails.git] / app / views / site / index.rhtml
index 27bcd618e34a1b173add177bc00cc469748f4341..f924f7a1431e8f3a4b7b301eb0da0c6dfad2250c 100644 (file)
@@ -8,6 +8,10 @@
 <%= render :partial => 'key' %>
 <%= render :partial => 'search' %>
 
+<noscript><div id="noscript"><p>You are either using a browser that doesn't support javascript, or you have disabled javascript.</p>
+<p>OpenStreetMap uses javascript for its slippy map.</p>
+<p>Try the <a href="http://tah.openstreetmap.org/Browse/">OpenStreetMap static tile browser</a>.</p></div></noscript>
+
 <div id="map">
 <div id="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
 </div> 
@@ -21,7 +25,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>
@@ -51,7 +55,7 @@ by the OpenStreetMap project and it's contributors.
 <% zoom =  h(params['zoom'] || '12') %>
 <% layers = h(params['layers']) %>
 <% elsif cookies.key?("location") %>
-<% lon,lat,zoom,layers = cookies["location"].value.first.split(",") %>
+<% lon,lat,zoom,layers = cookies["location"].split(",") %>
 <% elsif @user and !@user.home_lon.nil? and !@user.home_lat.nil? %> 
 <% lon =  @user.home_lon %>
 <% lat =  @user.home_lat %>
@@ -77,30 +81,28 @@ by the OpenStreetMap project and it's contributors.
 <%= javascript_include_tag 'map.js' %>
 
 
-<script type="text/javascript">
+<script type="text/javascript" defer="defer">
   <!--
   var brokenContentSize = $("content").offsetWidth == 0;
   var marker;
   var map;
 
-  function init(){
+  function mapInit(){
     map = createMap("map");
 
     <% if bbox %>
-    var min = lonLatToMercator(new OpenLayers.LonLat(<%= minlon %>, <%= minlat %>));
-    var max = lonLatToMercator(new OpenLayers.LonLat(<%= maxlon %>, <%= maxlat %>));
-    var bbox = new OpenLayers.Bounds(min.lon, min.lat, max.lon, max.lat);
+    var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>);
 
-    map.zoomToExtent(bbox);
+    setMapExtent(bbox);
     <% else %>
-    var centre = lonLatToMercator(new OpenLayers.LonLat(<%= lon %>, <%= lat %>));
+    var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>);
     var zoom = <%= zoom %>;
 
     <% if params['scale'] and params['scale'].length > 0 then %>
     zoom = scaleToZoom(<%= params['scale'].to_f() %>);
     <% end %>
 
-    map.setCenter(centre, zoom);
+    setMapCenter(centre, zoom);
     <% end %>
 
     <% if layers %>
@@ -108,7 +110,7 @@ by the OpenStreetMap project and it's contributors.
     <% end %>
 
     <% if marker %>
-    marker = addMarkerToMap(lonLatToMercator(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>)));
+    marker = addMarkerToMap(new OpenLayers.LonLat(<%= mlon %>, <%= mlat %>));
     <% end %>
 
     map.events.register("zoomend", map, updateKey);
@@ -121,13 +123,13 @@ by the OpenStreetMap project and it's contributors.
   }
 
   function getPosition() {
-    return mercatorToLonLat(map.getCenter());
+    return getMapCenter();
   }
 
   function setPosition(lat, lon, zoom) {
-    var centre = lonLatToMercator(new OpenLayers.LonLat(lon, lat));
+    var centre = new OpenLayers.LonLat(lon, lat);
 
-    map.setCenter(centre, zoom);
+    setMapCenter(centre, zoom);
 
     if (marker)
       removeMarkerFromMap(marker);
@@ -136,7 +138,7 @@ by the OpenStreetMap project and it's contributors.
   }
 
   function updateLocation() {
-    var lonlat = mercatorToLonLat(map.getCenter());
+    var lonlat = getMapCenter();
     var zoom = map.getZoom();
     var layers = getMapLayers();
 
@@ -177,8 +179,14 @@ by the OpenStreetMap project and it's contributors.
 
     resizeMap();
   }
+  
+  mapInit();
 
+  window.onload = handleResize;
   window.onresize = handleResize;
-  window.onload = init;
+
+  <% if params['action'] == 'export' %>
+  <%= remote_function :url => { :controller => 'export', :action => 'start' } %>
+  <% end %>
 // -->
 </script>