Zoom after search
This commit is contained in:
parent
92233b08bf
commit
322e6403bb
|
@ -1,2 +1,12 @@
|
||||||
class WelcomeController < ApplicationController
|
class WelcomeController < ApplicationController
|
||||||
|
def index
|
||||||
|
# Default coordinates: Boston center
|
||||||
|
@lat, @lng = 42.358431, -71.059773
|
||||||
|
@zoom = 15
|
||||||
|
address, city, state = params[:address], params[:city], params[:state]
|
||||||
|
if address && city && state
|
||||||
|
@lat, @lng = Address.find_lat_lng("#{address}, #{city}, #{state}")
|
||||||
|
@zoom = 18
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,19 @@
|
||||||
<%= stylesheet_link_tag "main" %>
|
<%= stylesheet_link_tag "main" %>
|
||||||
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" %>
|
<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" %>
|
||||||
<%= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" %>
|
<%= javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" %>
|
||||||
<%= javascript_include_tag "maps" %>
|
|
||||||
<%= javascript_include_tag "snowstorm" %>
|
<%= javascript_include_tag "snowstorm" %>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
var map;
|
||||||
|
var latlng = new google.maps.LatLng(<%= @lat %>, <%= @lng %>);
|
||||||
|
var myOptions = {
|
||||||
|
zoom: <%= @zoom %>,
|
||||||
|
center: latlng,
|
||||||
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||||
|
};
|
||||||
|
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
||||||
|
})
|
||||||
|
</script>
|
||||||
<%= csrf_meta_tag %>
|
<%= csrf_meta_tag %>
|
||||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -3,29 +3,19 @@
|
||||||
<p id="tagline">
|
<p id="tagline">
|
||||||
Claim responsibility for shoveling out a fire hydrant after it snows.
|
Claim responsibility for shoveling out a fire hydrant after it snows.
|
||||||
</p>
|
</p>
|
||||||
<form>
|
<%= form_tag root_path, :method => :get do %>
|
||||||
<label for="address">
|
<%= label_tag "address" %>
|
||||||
Address
|
<%= text_field_tag "address", params[:address], :tabindex => 1 %>
|
||||||
</label>
|
<%= label_tag "city" %>
|
||||||
<input id="address" name="address" type="text" value="" tabindex="1" />
|
<%= select_tag "city", '<option value="Boston" selected="selected">Boston</option>'.html_safe, :tabindex => 2 %>
|
||||||
<label for="city">
|
<%= label_tag "state" %>
|
||||||
City
|
<%= select_tag "state", '<option value="MA" selected="selected">Massachusetts</option>'.html_safe, :tabindex => 3 %>
|
||||||
</label>
|
<%= submit_tag "Find Fire Hydrants", :tabindex => 4 %>
|
||||||
<select id="city" name="city" tabindex="2">
|
<% end %>
|
||||||
<option value="Boston">Boston</option>
|
<%= image_tag "logos/boston.png", :alt => "City of Boston", :title => "City of Boston" %>
|
||||||
</select>
|
<%= image_tag "logos/cert.png", :alt => "Community Emergency Response Team", :title => "Community Emergency Response Team" %>
|
||||||
<label for="state">
|
<%= image_tag "logos/cfa.png", :alt => "Code for America", :title => "Code for America" %>
|
||||||
State
|
<%= image_tag "hydrant-in-snow.jpg" %>
|
||||||
</label>
|
|
||||||
<select id="state" name="state" tabindex="3">
|
|
||||||
<option value="MA">Massachusetts</option>
|
|
||||||
</select>
|
|
||||||
<button tabindex="4">Find Fire Hydrants</button>
|
|
||||||
</form>
|
|
||||||
<img id="boston-logo" src="images/logos/boston.png" alt="City of Boston" title="City of Boston" />
|
|
||||||
<img id="cert-logo" src="images/logos/cert.png" alt="Community Emergency Response Team" title="Community Emergency Response Team" />
|
|
||||||
<img id="cfa-logo" src="images/logos/cfa.png" alt="Code for America" title="Code for America" />
|
|
||||||
<img id="hydrant-in-snow" src="images/hydrant-in-snow.jpg">
|
|
||||||
</div>
|
</div>
|
||||||
<div id="map_canvas">
|
<div id="map_canvas">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,58 +1,4 @@
|
||||||
AdoptAHydrant::Application.routes.draw do
|
AdoptAHydrant::Application.routes.draw do
|
||||||
# The priority is based upon order of creation:
|
get "javascripts/:action" => "javascripts#action"
|
||||||
# first created -> highest priority.
|
|
||||||
|
|
||||||
# Sample of regular route:
|
|
||||||
# match 'products/:id' => 'catalog#view'
|
|
||||||
# Keep in mind you can assign values other than :controller and :action
|
|
||||||
|
|
||||||
# Sample of named route:
|
|
||||||
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
|
||||||
# This route can be invoked with purchase_url(:id => product.id)
|
|
||||||
|
|
||||||
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
|
||||||
# resources :products
|
|
||||||
|
|
||||||
# Sample resource route with options:
|
|
||||||
# resources :products do
|
|
||||||
# member do
|
|
||||||
# get 'short'
|
|
||||||
# post 'toggle'
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# collection do
|
|
||||||
# get 'sold'
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Sample resource route with sub-resources:
|
|
||||||
# resources :products do
|
|
||||||
# resources :comments, :sales
|
|
||||||
# resource :seller
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Sample resource route with more complex sub-resources
|
|
||||||
# resources :products do
|
|
||||||
# resources :comments
|
|
||||||
# resources :sales do
|
|
||||||
# get 'recent', :on => :collection
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Sample resource route within a namespace:
|
|
||||||
# namespace :admin do
|
|
||||||
# # Directs /admin/products/* to Admin::ProductsController
|
|
||||||
# # (app/controllers/admin/products_controller.rb)
|
|
||||||
# resources :products
|
|
||||||
# end
|
|
||||||
|
|
||||||
# You can have the root of your site routed with "root"
|
|
||||||
# just remember to delete public/index.html.
|
|
||||||
root :to => "welcome#index"
|
root :to => "welcome#index"
|
||||||
|
|
||||||
# See how all your routes lay out with "rake routes"
|
|
||||||
|
|
||||||
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
|
||||||
# Note: This route will make all actions in every controller accessible via GET requests.
|
|
||||||
# match ':controller(/:action(/:id(.:format)))'
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
$(function() {
|
|
||||||
var map;
|
|
||||||
|
|
||||||
var latlng = new google.maps.LatLng(42.358431,-71.059773);
|
|
||||||
var myOptions = {
|
|
||||||
zoom: 15,
|
|
||||||
center: latlng,
|
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
|
||||||
};
|
|
||||||
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
|
||||||
|
|
||||||
})
|
|
|
@ -48,14 +48,13 @@ label, input {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
input, select, option, button {
|
input, select, option, input[type="submit"] {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
||||||
font-size: 1.0em;
|
font-size: 1.0em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
input[type="submit"] {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
height: 2em;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue