Class: PostRunner::TrackView

Inherits:
Object
  • Object
show all
Defined in:
lib/postrunner/TrackView.rb

Instance Method Summary collapse

Constructor Details

#initialize(activity) ⇒ TrackView

Returns a new instance of TrackView.



21
22
23
24
25
# File 'lib/postrunner/TrackView.rb', line 21

def initialize(activity)
  @activity = activity
  @session = @activity.fit_activity.sessions[0]
  @has_geo_data = @session.has_geo_data?
end

Instance Method Details

#to_html(doc) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/postrunner/TrackView.rb', line 27

def to_html(doc)
  return unless @has_geo_data

  doc.head {
    doc.unique(:trackview_style) {
      doc.style(style)
      doc.link({ 'rel' => 'stylesheet',
                 'href' => 'openlayers/theme/default/style.css',
                 'type' => 'text/css' })
      doc.script({ 'src' => 'openlayers/OpenLayers.js' })
    }
    doc.script(java_script)
  }

  ViewFrame.new('Map', 600) {
    doc.div({ 'id' => 'map', 'class' => 'trackmap' })
  }.to_html(doc)
end