|
|
@@ -77,34 +77,35 @@
|
|
77
|
77
|
}
|
|
78
|
78
|
},
|
|
79
|
79
|
removeMarkers () {
|
|
80
|
|
- this.clearRoute()
|
|
|
80
|
+ this.clearMap()
|
|
81
|
81
|
this.markers = []
|
|
82
|
82
|
},
|
|
83
|
83
|
setRoute (a, b) {
|
|
84
|
|
- this.clearRoute()
|
|
|
84
|
+ this.clearMap()
|
|
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
|
|
87
|
87
|
this.directionsDisplay.setMap(this.$refs.gMap.$mapObject)
|
|
88
|
88
|
// -------------------------------------------------------
|
|
89
|
|
- let vm = this
|
|
90
|
|
- vm.directionsService.route({
|
|
|
89
|
+ this.directionsService.route({
|
|
91
|
90
|
origin: a.position,
|
|
92
|
91
|
destination: b.position,
|
|
93
|
92
|
travelMode: 'DRIVING'
|
|
94
|
|
- }, function (response, status) {
|
|
|
93
|
+ }, (response, status) => {
|
|
95
|
94
|
if (status === 'OK') {
|
|
96
|
|
- vm.directionsDisplay.setDirections(response)
|
|
97
|
|
- this.currentRoute = response
|
|
|
95
|
+ this.directionsDisplay.setDirections(response)
|
|
|
96
|
+ this.currentRoute = response.routes[0].overview_path
|
|
98
|
97
|
} else {
|
|
99
|
98
|
alert('Directions request failed due to ' + status)
|
|
100
|
99
|
}
|
|
101
|
100
|
})
|
|
102
|
101
|
},
|
|
103
|
|
- clearRoute () {
|
|
104
|
|
- if (this.directionsDisplay) this.directionsDisplay.setMap(null)
|
|
|
102
|
+ clearMap () {
|
|
|
103
|
+ if (this.directionsDisplay) {
|
|
|
104
|
+ this.directionsDisplay.setMap(null)
|
|
|
105
|
+ }
|
|
105
|
106
|
},
|
|
106
|
107
|
emitRoute () {
|
|
107
|
|
- /* if (this.currentRoute) */ this.$emit('updateRoute', this.currentRoute)
|
|
|
108
|
+ if (this.currentRoute) this.$emit('updateRoute', this.currentRoute)
|
|
108
|
109
|
console.log('emitting route')
|
|
109
|
110
|
}
|
|
110
|
111
|
}
|