diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb index 8124d4a33..4de490b2c 100644 --- a/app/controllers/browse_controller.rb +++ b/app/controllers/browse_controller.rb @@ -25,6 +25,13 @@ class BrowseController < ApplicationController @type = "relation" render :action => "not_found", :status => :not_found end + + def relation_map + @relation = Relation.find(params[:id]) + rescue ActiveRecord::RecordNotFound + @type = "relation" + render :action => "not_found", :status => :not_found + end def way @way = Way.find(params[:id], :include => [:way_tags, {:changeset => :user}, {:nodes => [:node_tags, {:ways => :way_tags}]}, :containing_relation_members]) @@ -45,6 +52,13 @@ class BrowseController < ApplicationController render :action => "not_found", :status => :not_found end + def way_map + @way = Way.find(params[:id]) + rescue ActiveRecord::RecordNotFound + @type = "way" + render :action => "not_found", :status => :not_found + end + def node @node = Node.find(params[:id]) @next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] ) @@ -60,6 +74,13 @@ class BrowseController < ApplicationController @type = "way" render :action => "not_found", :status => :not_found end + + def node_map + @node = Node.find(params[:id]) + rescue ActiveRecord::RecordNotFound + @type = "node" + render :action => "not_found", :status => :not_found + end def changeset @changeset = Changeset.find(params[:id]) @@ -74,4 +95,11 @@ class BrowseController < ApplicationController @type = "changeset" render :action => "not_found", :status => :not_found end + + def changeset_map + @changeset = Changeset.find(params[:id]) + rescue ActiveRecord::RecordNotFound + @type = "changeset" + render :action => "not_found", :status => :not_found + end end diff --git a/app/views/browse/_big_map.html.erb b/app/views/browse/_big_map.html.erb new file mode 100644 index 000000000..329017026 --- /dev/null +++ b/app/views/browse/_big_map.html.erb @@ -0,0 +1,119 @@ +<% +# Decide on a lat lon to initialise the map with +if params['lon'] and params['lat'] + lon = h(params['lon']) + lat = h(params['lat']) + zoom = h(params['zoom'] || '5') + layers = h(params['layers']) +end +%> +<%= javascript_include_tag '/openlayers/OpenLayers.js' %> +<%= javascript_include_tag '/openlayers/OpenStreetMap.js' %> +<%= javascript_include_tag 'map.js' %> + + <% if big_map.instance_of? Changeset or big_map.visible %> +
+ +
+ <% else %> + <%= t 'browse.map.deleted' %> + <% end %> + +<% if big_map.instance_of? Changeset or big_map.visible %> + +<% end %> diff --git a/app/views/browse/_map.html.erb b/app/views/browse/_map.html.erb index 7c242d861..9a150ae05 100644 --- a/app/views/browse/_map.html.erb +++ b/app/views/browse/_map.html.erb @@ -7,6 +7,8 @@ <%= t 'browse.map.loading' %> +
+ <% else %> <%= t 'browse.map.deleted' %> <% end %> @@ -32,8 +34,11 @@ $("loading").innerHTML = ""; - $("larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes'; + $("larger_map").href = '<%= url_for :controller => 'browse', :action => (map.class.to_s.downcase + '_map'), :id => map.id, :only_path => true %>'; $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>"; + + $("main_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes'; + $("main_map").innerHTML = "<%= t 'browse.map.view_main_map' %>"; <% else %> var obj_type = "<%= map.class.name.downcase %>"; var obj_id = <%= map.id %>; @@ -65,8 +70,12 @@ } var center = getMapCenter(); - $("larger_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom(); + + $("larger_map").href = '<%= url_for :controller => 'browse', :action => (map.class.to_s.downcase + '_map'), :id => map.id, :only_path => true %>'; $("larger_map").innerHTML = "<%= t 'browse.map.view_larger_map' %>"; + + $("main_map").href = '/?lat='+center.lat+'&lon='+center.lon+'&zoom='+this.map.getZoom(); + $("main_map").innerHTML = "<%= t 'browse.map.view_main_map' %>"; } else { $("small_map").style.display = "none"; } diff --git a/app/views/browse/changeset_map.html.erb b/app/views/browse/changeset_map.html.erb new file mode 100644 index 000000000..8c3bdbe6c --- /dev/null +++ b/app/views/browse/changeset_map.html.erb @@ -0,0 +1,5 @@ +<% +@name = printable_name @changeset +@title = t('browse.changeset.map_title', :name => @name) +%> +<%= render :partial => "big_map", :object => @changeset %> diff --git a/app/views/browse/node_map.html.erb b/app/views/browse/node_map.html.erb new file mode 100644 index 000000000..4404e0c2b --- /dev/null +++ b/app/views/browse/node_map.html.erb @@ -0,0 +1,5 @@ +<% +@name = printable_name @node +@title = t('browse.node.map_title', :name => @name) +%> +<%= render :partial => "big_map", :object => @node %> diff --git a/app/views/browse/relation_map.html.erb b/app/views/browse/relation_map.html.erb new file mode 100644 index 000000000..15f001303 --- /dev/null +++ b/app/views/browse/relation_map.html.erb @@ -0,0 +1,5 @@ +<% +@name = printable_name @relation +@title = t('browse.relation.map_title', :name => @name) +%> +<%= render :partial => "big_map", :object => @relation %> diff --git a/app/views/browse/way_map.html.erb b/app/views/browse/way_map.html.erb new file mode 100644 index 000000000..2b4d8b2e4 --- /dev/null +++ b/app/views/browse/way_map.html.erb @@ -0,0 +1,5 @@ +<% +@name = printable_name @way +@title = t('browse.way.map_title', :name => @name) +%> +<%= render :partial => "big_map", :object => @way %> diff --git a/config/locales/en.yml b/config/locales/en.yml index f8dc9535f..b475335d5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -79,6 +79,7 @@ en: browse: changeset: title: "Changeset" + map_title: "Changeset | {{name}}" changeset: "Changeset:" download: "Download {{changeset_xml_link}} or {{osmchange_xml_link}}" changesetxml: "Changeset XML" @@ -106,6 +107,7 @@ en: loading: "Loading..." deleted: "Deleted" view_larger_map: "View Larger Map" + view_main_map: "View on main map" node_details: coordinates: "Coordinates: " part_of: "Part of:" @@ -117,6 +119,7 @@ en: view_details: "view details" node: node: "Node" + map_title: "Node | {{name}}" node_title: "Node: {{node_name}}" download: "{{download_xml_link}}, {{view_history_link}} or {{edit_link}}" download_xml: "Download XML" @@ -141,6 +144,7 @@ en: as: "as" relation: relation: "Relation" + map_title: "Relation | {{name}}" relation_title: "Relation: {{relation_name}}" download: "{{download_xml_link}} or {{view_history_link}}" download_xml: "Download XML" @@ -199,6 +203,7 @@ en: view_details: "view details" way: way: "Way" + map_title: "Way | {{name}}" way_title: "Way: {{way_name}}" download: "{{download_xml_link}}, {{view_history_link}} or {{edit_link}}" download_xml: "Download XML" diff --git a/config/locales/is.yml b/config/locales/is.yml index 883621ff1..88412a6e9 100644 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@ -79,6 +79,7 @@ is: browse: changeset: title: "Breytingarsett" + map_title: "Breytingarsett | {{name}}" changeset: "Breytingarsett:" download: "Niðurhala breytingunni á {{changeset_xml_link}} eða á {{osmchange_xml_link}}" changesetxml: "Breytingarsetts XML sniði" @@ -110,6 +111,7 @@ is: loading: "Hleð..." deleted: "Eytt" view_larger_map: "Skoða á stærra korti" + view_main_map: "Skoða á aðalkorti" node_details: coordinates: "Hnit: " part_of: "Hluti af:" @@ -121,6 +123,7 @@ is: view_details: "sýna breytingarsögu" node: node: "Hnútur" + map_title: "Hnútur | {{name}}" node_title: "Hnútur: {{node_name}}" download: "{{download_xml_link}} eða {{view_history_link}} eða {{edit_link}}" download_xml: "Hala niður á XML sniði" @@ -145,6 +148,7 @@ is: as: "sem" relation: relation: "Vensl" + map_title: "Vensl | {{name}}" relation_title: "Vensl: {{relation_name}}" download: "{{download_xml_link}} eða {{view_history_link}}" download_xml: "Hala niður á XML sniði" @@ -202,6 +206,7 @@ is: view_details: "sýna breytingarsögu" way: way: "Vegur" + map_title: "Vegur | {{name}}" way_title: "Vegur: {{way_name}}" download: "{{download_xml_link}} eða {{view_history_link}} eða {{edit_link}}" download_xml: "Hala niður á XML sniði" diff --git a/config/routes.rb b/config/routes.rb index 6dd3860dc..8ca792a61 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,12 +76,16 @@ ActionController::Routing::Routes.draw do |map| map.connect '/browse', :controller => 'changeset', :action => 'list' map.connect '/browse/start', :controller => 'browse', :action => 'start' map.connect '/browse/way/:id', :controller => 'browse', :action => 'way', :id => /\d+/ + map.connect '/browse/way/:id/map', :controller => 'browse', :action => 'way_map', :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/map', :controller => 'browse', :action => 'node_map', :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/map', :controller => 'browse', :action => 'relation_map', :id => /\d+/ map.connect '/browse/relation/:id/history', :controller => 'browse', :action => 'relation_history', :id => /\d+/ map.connect '/browse/changeset/:id', :controller => 'browse', :action => 'changeset', :id => /\d+/ + map.connect '/browse/changeset/:id/map', :controller => 'browse', :action => 'changeset_map', :id => /\d+/ map.connect '/browse/changesets', :controller => 'changeset', :action => 'list' # web site