]> git.openstreetmap.org Git - rails.git/blobdiff - app/views/site/index.html.erb
Handle openlayers.js as a template
[rails.git] / app / views / site / index.html.erb
index 242890e28df73c769f658c068db52abb98280b3e..ee95bf7913aca7c938c95f4ad7b1811dfbdf866d 100644 (file)
@@ -1,7 +1,7 @@
-<% content_for :greeting do %>
 <% if @user and !@user.home_lon.nil? and !@user.home_lat.nil? %>
-  <%= link_to_function t('layouts.home'), "setPosition(#{@user.home_lat}, #{@user.home_lon}, 15)", { :title => t('layouts.home_tooltip') } %> |
-<% end %>
+  <% content_for :greeting do %>
+    <%= link_to_function t('layouts.home'), "setPosition(#{@user.home_lat}, #{@user.home_lon}, 15)", { :title => t('layouts.home_tooltip') } %> |
+  <% end %>
 <% end %>
 
 <%= render :partial => 'sidebar', :locals => { :onopen => "resizeMap();", :onclose => "resizeMap();" } %>
@@ -68,7 +68,7 @@ end
 # Decide on a lat lon to initialise the map with. Various ways of doing this
 if params[:bbox]
     bbox = true
-    minlon, minlat, maxlon, maxlat = params[:bbox].split(",").collect { |c| c.to_i }
+    minlon, minlat, maxlon, maxlat = params[:bbox].split(",").collect { |c| c.to_f }
     layers = params[:layers]
     box = true if params[:box] == "yes"
     object_zoom = false
@@ -120,8 +120,7 @@ else
 end
 %>
 
-<%= javascript_include_tag '/openlayers/OpenLayers.js' %>
-<%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
+<%= javascript_include_tag 'openlayers.js' %>
 <%= javascript_include_tag 'map.js' %>
 
 <%= render :partial => 'resize' %>
@@ -160,8 +159,6 @@ end
 
         setMapCenter(centre, zoom);
       <% end %>
-
-      updateLocation();
     <% end %>
 
     <% if !layers.nil? and !layers.empty? %>
@@ -185,6 +182,7 @@ end
     map.events.register("moveend", map, updateLocation);
     map.events.register("changelayer", map, updateLocation);
 
+    updateLocation();
     handleResize();
   }
 
@@ -280,7 +278,15 @@ end
     map.setCenter(centre, zoom);
   });
 
-  <% if params[:action] == 'export' %>
-  <%= remote_function :url => { :controller => 'export', :action => 'start' } %>
-  <% end %>
+  document.observe("dom:loaded", function () {
+    $("exportanchor").observe("click", function (e) {
+      <%= remote_function :url => { :controller => 'export', :action => 'start' } %>;
+      Event.stop(e);
+    });
+
+    <% if params[:action] == 'export' %>
+    <%= remote_function :url => { :controller => 'export', :action => 'start' } %>;
+    <% end %>
+  });
+// -->
 </script>