瀏覽代碼

adding grades

Jared Norris 8 年之前
父節點
當前提交
037f812ffd
共有 2 個文件被更改,包括 26 次插入16 次删除
  1. 26
    15
      VueApp/src/components/ElevationGraph.vue
  2. 0
    1
      VueApp/src/components/GoogleMap.vue

+ 26
- 15
VueApp/src/components/ElevationGraph.vue 查看文件

@@ -1,10 +1,12 @@
1 1
 <template>
2
-  <GChart
3
-    v-if="chartData"
4
-    type="ColumnChart"
5
-    :data="chartData"
6
-    :options="chartOptions"
7
-  />
2
+  <div class="chartContainer" v-if="chartData">
3
+    <GChart
4
+      type="ColumnChart"
5
+      :data="chartData"
6
+      :options="chartOptions"
7
+    />
8
+    <div class="miles">{{ this.miles }}</div>
9
+  </div>
8 10
 </template>
9 11
 
10 12
 <script>
@@ -15,12 +17,17 @@
15 17
     components: { GChart },
16 18
     props: ['currentRoute'],
17 19
     watch: {
18
-      currentRoute (newVal) {
19
-        this.getPathElevation(newVal)
20
+      currentRoute (newRoute) {
21
+        console.log(newRoute)
22
+        this.miles = newRoute.legs[0].distance.text
23
+        this.getPathElevation(newRoute.overview_path)
20 24
       }
21 25
     },
22 26
     data () {
23 27
       return {
28
+        miles: null,
29
+        avgGrade: null,
30
+        peakGrade: null,
24 31
         elevationService: null,
25 32
         chartData: null,
26 33
         chartOptions: {
@@ -34,21 +41,16 @@
34 41
     },
35 42
     methods: {
36 43
       getPathElevation (route) {
37
-        let path = []
38
-        route.forEach(e => path.push({
39
-          lat: e.lat(),
40
-          lng: e.lng()
41
-        }))
42
-        // -----------------------------
43 44
         this.elevationService = new google.maps.ElevationService() // eslint-disable-line no-undef
44 45
         this.chartData = [
45 46
           ['', '', { role: 'style' }]
46 47
         ]
47 48
         this.elevationService.getElevationAlongPath({
48
-          'path': path,
49
+          'path': route,
49 50
           'samples': 264
50 51
         }, (elevations, status) => {
51 52
           if (status === 'OK') {
53
+            console.log(elevations)
52 54
             elevations.forEach((e, i) =>
53 55
               Math.abs(e.elevation - elevations[i + 1].elevation) > 1
54 56
                 ? this.chartData.push(['', e.elevation, '#CAE9FF'])
@@ -58,10 +60,19 @@
58 60
             )
59 61
           }
60 62
         })
63
+      },
64
+      getAverageGrade () {
65
+
66
+      },
67
+      getPeakGrade () {
68
+
61 69
       }
62 70
     }
63 71
   }
64 72
 </script>
65 73
 
66 74
 <style scoped>
75
+  .miles {
76
+    color: white;
77
+  }
67 78
 </style>

+ 0
- 1
VueApp/src/components/GoogleMap.vue 查看文件

@@ -102,7 +102,6 @@
102 102
           'updateRoute', this.directionsDisplay
103 103
             .getDirections()
104 104
             .routes[0]
105
-            .overview_path
106 105
         )
107 106
       }
108 107
     }