Class: PostRunner::TrackView
- Inherits:
-
Object
- Object
- PostRunner::TrackView
- Defined in:
- lib/postrunner/TrackView.rb
Overview
A TrackView object uses OpenLayers to draw a map with the waypoints of the activity. Lap end are marked with enumerated lap markers.
Instance Method Summary collapse
-
#initialize(activity) ⇒ TrackView
constructor
Create a new TrackView object for a given Activity.
-
#to_html(doc) ⇒ Object
Render the map widget with the track and marker overlay as HTML code.
Constructor Details
#initialize(activity) ⇒ TrackView
Create a new TrackView object for a given Activity.
25 26 27 28 29 |
# File 'lib/postrunner/TrackView.rb', line 25 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
Render the map widget with the track and marker overlay as HTML code.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/postrunner/TrackView.rb', line 33 def to_html(doc) return unless @has_geo_data doc.body_init_script('pr_trackview_init_xy();') doc.head { doc.unique(:trackview_style) { doc.style(style) doc.link({ 'rel' => 'stylesheet', 'href' => 'openlayers/ol.css', 'type' => 'text/css' }) doc.script({ 'language' => 'javascript', 'type' => 'text/javascript', 'src' => 'openlayers/ol.js' }) doc.script({ 'language' => 'javascript', 'type' => 'text/javascript', 'src' => 'postrunner/trackview.js' }) } doc.script(java_script) } ViewFrame.new('map', 'Map', 600, nil, true) { doc.div({ 'id' => 'map', 'class' => 'trackmap' }) }.to_html(doc) end |