Skip to content

Commit cf6daf6

Browse files
committed
and it's working!!!
1 parent f8a5aa5 commit cf6daf6

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "traccar-route-replay",
3-
"version": "1.2.7",
3+
"version": "1.2.8",
44
"private": true,
55
"scripts": {
66
"dev": "nuxt",

pages/index.vue

+26-9
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export default {
116116
loading: false,
117117
playing: false,
118118
i: 0,
119+
start: 0,
119120
playSpeed: 400,
120121
follow: false,
121122
sliderBackground: ''
@@ -167,10 +168,11 @@ export default {
167168
await this.$store.dispatch('getPath')
168169
this.loading = false
169170
},
171+
start () {
172+
this.updateRoute()
173+
},
170174
i () {
171-
if (this.i > 1 && map.getSource('route')) {
172-
map.getSource('route').setData(lineString(this.path.slice(0, this.i)))
173-
}
175+
this.updateRoute()
174176
if (this.path[this.i]) {
175177
if (this.playing) {
176178
this.updateSlider()
@@ -375,13 +377,15 @@ export default {
375377
})
376378
this.$refs.noUiSlider.noUiSlider.on('update', ([from, to]) => {
377379
this.currentTime = to
378-
const start = closest(this.timestamps, from)
379-
if (start && map.getSource('route')) {
380-
map.getSource('route').setData(lineString(this.path.slice(start)))
381-
}
380+
this.start = closest(this.timestamps, from)
382381
})
383382
},
384383
methods: {
384+
updateRoute () {
385+
if (this.start > 0 && this.i > this.start && map.getSource('route')) {
386+
map.getSource('route').setData(lineString(this.path.slice(this.start, this.i)))
387+
}
388+
},
385389
updateSlider () {
386390
this.$refs.noUiSlider.noUiSlider.set([null, this.currentTime])
387391
},
@@ -557,8 +561,21 @@ export default {
557561
type: 'line',
558562
source: 'route',
559563
paint: {
560-
'line-color': green,
561-
'line-width': 8
564+
'line-color': '#2d5f99',
565+
'line-width': 10
566+
},
567+
layout: {
568+
'line-join': 'round',
569+
'line-cap': 'round'
570+
}
571+
})
572+
map.addLayer({
573+
id: 'routeCasing',
574+
type: 'line',
575+
source: 'route',
576+
paint: {
577+
'line-color': '#4882c5',
578+
'line-width': 5
562579
},
563580
layout: {
564581
'line-join': 'round',

0 commit comments

Comments
 (0)