Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google map #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

group :development, :test do

gem 'pry-byebug'
gem 'rspec-rails'
gem 'rails-controller-testing'
Expand Down
17 changes: 13 additions & 4 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
@import "bootstrap";

.Page-Title {
font-size:30px;
font-weight:bold;
text-align:center;
font-size:30px;
font-weight:bold;
text-align:center;
}

.panel-footer {
background-color: white;
background-color: white;
}

.contact-header {
Expand All @@ -31,3 +31,12 @@
.questions {
margin-left: 10%;
}

#map_wrapper {
height: 400px;
}

#map_canvas {
width: 100%;
height: 100%;
}
29 changes: 27 additions & 2 deletions app/controllers/listings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
class ListingsController < ApplicationController
skip_before_action :verify_authenticity_token

def get_map_points
map_points = [{lat:42.3601, long:-71.0589}]

@listings = Listing.all

@listings.each do |point|
array = []

if point.latitude.to_f > 41.6821 &&
point.latitude.to_f < 42.9337 &&
point.longitude.to_f < -69.9598 &&
point.longitude.to_f > -72.2781

array << point.address
array << point.latitude
array << point.longitude
end

map_points << array
end

respond_to do |format|
format.html
format.json { render json: { data: map_points } }
end
end

def index
@listings = Listing.paginate(:page => params[:page], :per_page => 50)
respond_to do |format|
Expand Down Expand Up @@ -44,7 +71,6 @@ def create

def discriminatory
@listings = Listing.discriminatory
binding.pry
render_listings_formats
end

Expand Down Expand Up @@ -74,5 +100,4 @@ def render_listings_formats
format.json {render json: @listings.to_json}
end
end

end
116 changes: 60 additions & 56 deletions app/views/listings/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,64 +36,68 @@

<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<div class="container">
<div class="row">
<div class="col-sm-12" id="scrape-button">
<%= button_to "Run Scraper", scrapers_path, class: 'btn btn-primary btn-block' %>
</div>
<div id="map_wrapper">
<div id="map_canvas" class="mapping"></div>
</div>

<div class="container">
<div class="row">
<div class="col-sm-12" id="scrape-button">
<%= button_to "Run Scraper", scrapers_path, class: 'btn btn-primary btn-block' %>
</div>
<div class="row">
<div class="col-sm-12">
<table class="table" data-toggle="table" >
<thead>
<tr>
<th data-sortable="true" class="heading-label">heading</th>
<th data-sortable="true" class="date-time-label">listed at</th>
<th data-sortable="true" class="address-label">address</th>
<th data-sortable="true" class="latitude-label">latitude</th>
<th data-sortable="true" class="longitude-label">longitude</th>
<th data-sortable="true" class="description-label">description</th>
<th data-sortable="true" class="descriminatory-label">discriminatory</th>
</div>
<div class="row">
<div class="col-sm-12">
<table class="table" data-toggle="table" >
<thead>
<tr>
<th data-sortable="true" class="heading-label">heading</th>
<th data-sortable="true" class="date-time-label">listed at</th>
<th data-sortable="true" class="address-label">address</th>
<th data-sortable="true" class="latitude-label">latitude</th>
<th data-sortable="true" class="longitude-label">longitude</th>
<th data-sortable="true" class="description-label">description</th>
<th data-sortable="true" class="descriminatory-label">discriminatory</th>
</tr>
</thead>
<tbody>
<% @listings.each do |listing| %>
<tr class="housing-column">
<td class="heading-item"><%= link_to listing.heading, listing_path(listing) %></td>
<td class="date-time-item"><%= listing.listed_at %></td>
<td class="address-item"><%= listing.address %></td>
<td class="latitude-item"><%= listing.latitude %></td>
<td class="longitude-item"><%= listing.longitude %></td>
<td class="description-item"><%= listing.description %></td>
<td class="descriminatory-item"><%= listing.discriminatory %></td>
</tr>
</thead>
<tbody>
<% @listings.each do |listing| %>
<tr class="housing-column">
<td class="heading-item"><%= link_to listing.heading, listing_path(listing) %></td>
<td class="date-time-item"><%= listing.listed_at %></td>
<td class="address-item"><%= listing.address %></td>
<td class="latitude-item"><%= listing.latitude %></td>
<td class="longitude-item"><%= listing.longitude %></td>
<td class="description-item"><%= listing.description %></td>
<td class="descriminatory-item"><%= listing.discriminatory %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="panel-footer">
<div class="row">
<div class="col col-xs-offset-3 col-xs-6">
<nav aria-label="Page navigation" class="text-center">
<ul class="pagination">
<li>
<a href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li class="active"><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li>
<a href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
<% end %>
</tbody>
</table>
<div class="panel-footer">
<div class="row">
<div class="col col-xs-offset-3 col-xs-6">
<nav aria-label="Page navigation" class="text-center">
<ul class="pagination">
<li>
<a href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li class="active"><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li>
<a href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
Rails.application.config.assets.precompile += %w( google.js )
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
post '/tools/trackchanges', to: 'trackchanges#get_changes'
get '/tools/trackform', to: 'trackchanges#trackform'
get '/Contact', to: 'contacts#index'
post '/mappoints', to: 'listings#get_map_points'
end