소스 검색

need to fix route emit

Jared Norris 8 년 전
부모
커밋
a62b6ce8ff
3개의 변경된 파일41개의 추가작업 그리고 33개의 파일을 삭제
  1. 28
    28
      VueApp/src/components/ElevationGraph.vue
  2. 3
    2
      VueApp/src/components/GoogleMap.vue
  3. 10
    3
      VueApp/src/components/Main.vue

+ 28
- 28
VueApp/src/components/ElevationGraph.vue 파일 보기

@@ -7,38 +7,38 @@
7 7
 </template>
8 8
 
9 9
 <script>
10
-    import { GChart } from 'vue-google-charts'
10
+  import { GChart } from 'vue-google-charts'
11 11
 
12
-    export default {
13
-        name: "ElevationGraph",
14
-        components: { GChart },
15
-        data () {
16
-          return {
17
-            currentRoute: null,
18
-            elevationService: null,
19
-            chartData: [],
20
-            chartOptions: {
21
-              chart: {
22
-                title: 'Elevation Report'
23
-              }
24
-            }
25
-          }
26
-        },
27
-        methods: {
28
-          getPathElevation (currentRoute) {
29
-            this.chartData = []
30
-            this.elevationService = new google.maps.ElevationService() // eslint-disable-line no-undef
31
-            this.elevationService.getElevationAlongPath({
32
-              'path': currentRoute,
33
-              'samples': 256
34
-            }, function (elevations, status) {
35
-               if (status === 'OK') {
36
-                  elevations.forEach(e => this.chartData.push(['', e.elevation]))
37
-               }
38
-            })
12
+  export default {
13
+    name: 'ElevationGraph',
14
+    components: { GChart },
15
+    data () {
16
+      return {
17
+        currentRoute: null,
18
+        elevationService: null,
19
+        chartData: [],
20
+        chartOptions: {
21
+          chart: {
22
+            title: 'Elevation Report'
39 23
           }
40 24
         }
25
+      }
26
+    },
27
+    methods: {
28
+      getPathElevation () {
29
+        this.chartData = []
30
+        this.elevationService = new google.maps.ElevationService() // eslint-disable-line no-undef
31
+        this.elevationService.getElevationAlongPath({
32
+          'path': this.currentRoute,
33
+          'samples': 256
34
+        }, function (elevations, status) {
35
+          if (status === 'OK') {
36
+            elevations.forEach(e => this.chartData.push(['', e.elevation]))
37
+          }
38
+        })
39
+      }
41 40
     }
41
+  }
42 42
 </script>
43 43
 
44 44
 <style scoped>

+ 3
- 2
VueApp/src/components/GoogleMap.vue 파일 보기

@@ -80,7 +80,7 @@
80 80
         this.clearRoute()
81 81
         this.markers = []
82 82
       },
83
-      setRoute: function (a, b) {
83
+      setRoute (a, b) {
84 84
         this.clearRoute()
85 85
         this.directionsService = new google.maps.DirectionsService() // eslint-disable-line no-undef
86 86
         this.directionsDisplay = new google.maps.DirectionsRenderer({ draggable: true }) // eslint-disable-line no-undef
@@ -104,7 +104,8 @@
104 104
         if (this.directionsDisplay) this.directionsDisplay.setMap(null)
105 105
       },
106 106
       emitRoute () {
107
-        if (this.currentRoute) this.$emit('currentRoute', this.currentRoute)
107
+        /* if (this.currentRoute) */ this.$emit('updateRoute', this.currentRoute)
108
+        console.log('emitting route')
108 109
       }
109 110
     }
110 111
   }

+ 10
- 3
VueApp/src/components/Main.vue 파일 보기

@@ -4,16 +4,17 @@
4 4
       <img src="http://via.placeholder.com/1000x100"/>
5 5
     </div>
6 6
     <div class="mainMap">
7
-      <google-map/>
7
+      <GoogleMap v-on:updateRoute="updateElevation"/>
8 8
     </div>
9 9
     <div class="infoGraphic">
10
-      <img src="http://via.placeholder.com/800x100"/>
10
+      <ElevationGraph/>
11 11
     </div>
12 12
   </div>
13 13
 </template>
14 14
 
15 15
 <script>
16 16
   import GoogleMap from './GoogleMap.vue'
17
+  import ElevationGraph from './ElevationGraph.vue'
17 18
   export default {
18 19
     name: 'main',
19 20
     props: ['auth', 'authenticated'],
@@ -21,7 +22,13 @@
21 22
       this.auth.login()
22 23
     },
23 24
     components: {
24
-      GoogleMap
25
+      GoogleMap,
26
+      ElevationGraph
27
+    },
28
+    methods: {
29
+      updateElevation (route) {
30
+        console.log(route)
31
+      }
25 32
     }
26 33
   }
27 34
 </script>