Skip to content

Commit c53f1b7

Browse files
committed
almost there
1 parent 95957e0 commit c53f1b7

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "traccar-route-replay",
3-
"version": "1.2.6",
3+
"version": "1.2.7",
44
"private": true,
55
"scripts": {
66
"dev": "nuxt",
@@ -17,7 +17,7 @@
1717
"@deck.gl/mapbox": "8.9.34",
1818
"@deck.gl/mesh-layers": "8.9.34",
1919
"@nuxtjs/axios": "^5.13.6",
20-
"@nuxtjs/i18n": "^7.3.1",
20+
"@nuxtjs/i18n": "7.3.1",
2121
"@turf/bbox": "^6.5.0",
2222
"@turf/bearing": "^6.5.0",
2323
"@turf/circle": "^6.5.0",

pages/index.vue

+21-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<button
1515
class="mapboxgl-ctrl-icon svg-button"
1616
style="background-image: url('backward.svg')"
17-
@click="(i - 1 >= 0) && i--"
17+
@click="clickBackward"
1818
/>
1919
<button
2020
class="mapboxgl-ctrl-icon svg-button"
@@ -24,7 +24,7 @@
2424
<button
2525
class="mapboxgl-ctrl-icon svg-button"
2626
style="background-image: url('forward.svg')"
27-
@click="(i + 1 < path.length) && i++"
27+
@click="clickForward"
2828
/>
2929
<div class="mapboxgl-ctrl-timeline__label">
3030
<input v-model="from" type="datetime-local">
@@ -44,9 +44,6 @@
4444
<label for="follow">{{ $t('Follow vehicle') }}</label>
4545
</div>
4646
</div>
47-
<div ref="datetime" class="mapboxgl-ctrl mapboxgl-ctrl-group mapboxgl-ctrl-timeline__label" style="padding: 3px">
48-
{{ timestamps[i] && new Date(timestamps[i]).toLocaleString() }}
49-
</div>
5047
<div ref="speedometer" class="mapboxgl-ctrl">
5148
<speedometer :speed="route[i] && route[i].speed * 1.852" />
5249
</div>
@@ -152,9 +149,6 @@ export default {
152149
}
153150
},
154151
watch: {
155-
/* currentTime (value) {
156-
this.$refs.noUiSlider.noUiSlider.set([value])
157-
}, */
158152
geofences () {
159153
const features = featureCollection(
160154
this.geofences
@@ -178,6 +172,9 @@ export default {
178172
map.getSource('route').setData(lineString(this.path.slice(0, this.i)))
179173
}
180174
if (this.path[this.i]) {
175+
if (this.playing) {
176+
this.updateSlider()
177+
}
181178
const model = get3dModel(this.device && this.device.category)
182179
overlay.setProps({
183180
layers: [new ScenegraphLayer({
@@ -348,7 +345,6 @@ export default {
348345
map.on('style.load', this.styleLoaded)
349346
map.on('styleimagemissing', this.styleImageMissing)
350347
map.addControl({ onAdd: () => this.$refs.slider }, 'top-right')
351-
map.addControl({ onAdd: () => this.$refs.datetime }, 'top-right')
352348
map.addControl({ onAdd: () => this.$refs.speedometer }, 'top-right')
353349
map.addControl(new mapboxgl.NavigationControl())
354350
map.addControl({ onAdd: () => this.$refs.styleSwitcher })
@@ -366,6 +362,7 @@ export default {
366362
{ to: value => new Date(value).toLocaleString() },
367363
{ to: value => new Date(value).toLocaleString() }
368364
],
365+
step: 1,
369366
pips: {
370367
mode: 'positions',
371368
values: [0, 50, 100],
@@ -379,6 +376,21 @@ export default {
379376
this.$refs.noUiSlider.noUiSlider.on('update', ([from, to]) => { this.currentTime = to })
380377
},
381378
methods: {
379+
updateSlider () {
380+
this.$refs.noUiSlider.noUiSlider.set([null, this.currentTime])
381+
},
382+
clickBackward () {
383+
if (this.i - 1 >= 0) {
384+
this.i--
385+
this.updateSlider()
386+
}
387+
},
388+
clickForward () {
389+
if (this.i + 1 < this.path.length) {
390+
this.i++
391+
this.updateSlider()
392+
}
393+
},
382394
styleImageMissing (e) {
383395
if (e.id.startsWith('regulatory')) {
384396
const img = new Image(20, 20)

0 commit comments

Comments
 (0)