|
|
@@ -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>
|