]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/site_controller.rb
Refactor search JS
[rails.git] / app / controllers / site_controller.rb
index c16daf37facb7ff7e2ac64ebe267d988be6cf874..3b0a19cf91d70d2c516076ca4ab71074fe1dc886 100644 (file)
@@ -8,9 +8,20 @@ class SiteController < ApplicationController
   before_filter :require_oauth, :only => [:index]
 
   def index
+    anchor = []
+
     if params[:lat] && params[:lon]
-      params[:anchor] = "#{params.delete(:zoom) || 5}/#{params.delete(:lat)}/#{params.delete(:lon)}"
-      redirect_to params
+      anchor << "map=#{params.delete(:zoom) || 5}/#{params.delete(:lat)}/#{params.delete(:lon)}"
+    end
+
+    if params[:layers]
+      anchor << "layers=#{params.delete(:layers)}"
+    elsif params.delete(:notes) == 'yes'
+      anchor << "layers=N"
+    end
+
+    if anchor.present?
+      redirect_to params.merge(:anchor => anchor.join('&'))
       return
     end
 
@@ -31,7 +42,7 @@ class SiteController < ApplicationController
 
     new_params[:controller] = 'site'
     new_params[:action] = 'index'
-    new_params[:anchor] = "#{zoom}/#{lat}/#{lon}"
+    new_params[:anchor] = "map=#{zoom}/#{lat}/#{lon}"
 
     redirect_to new_params
   end