diff --git a/app/assets/javascripts/events.coffee b/app/assets/javascripts/events.coffee index 24f83d1..cd2cbdf 100644 --- a/app/assets/javascripts/events.coffee +++ b/app/assets/javascripts/events.coffee @@ -1,3 +1,16 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ +ready = -> + mapCanvas = document.getElementById('map-canvas') + data = mapCanvas.dataset + coords = new (google.maps.LatLng)(data.lat, data.long) + mapOptions = + center: coords + zoom: 16 + mapTypeId: google.maps.MapTypeId.ROADMAP + map = new (google.maps.Map)(mapCanvas, mapOptions) + marker = new (google.maps.Marker)( + position: coords + map: map) + return + +$(document).ready(ready) +$(document).on('page:load', ready) \ No newline at end of file diff --git a/app/assets/stylesheets/events.scss b/app/assets/stylesheets/events.scss index e975d96..e9c39e4 100644 --- a/app/assets/stylesheets/events.scss +++ b/app/assets/stylesheets/events.scss @@ -1,3 +1,8 @@ // Place all the styles related to the Events controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +#map-canvas { + width: 500px; + height: 400px; +} \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..8d9b7cb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,8 @@ module ApplicationHelper + def map_for_coords(coords) + tag("div", + id: "map-canvas", + data: { lat: coords[0], long: coords[1] } + ) + end end diff --git a/app/models/event.rb b/app/models/event.rb index ca4fc06..bdc8b81 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -58,7 +58,7 @@ def format_speakers def format_people (self.candidates.map(&:person_name) + self.people.map(&:full_name)).uniq.join(', ') - end + end def format_location v = self.venue @@ -69,6 +69,14 @@ def format_location end end + def coords + if venue + [venue.latitude, venue.longitude] + else + [] + end + end + def add_candidate(candidate_id) candidate = Candidate.includes(:person).find(candidate_id) self.candidates << candidate if candidate diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb index 9b99e31..c601c45 100644 --- a/app/views/events/show.html.erb +++ b/app/views/events/show.html.erb @@ -4,11 +4,11 @@ <%= notice %> <% end %> -