Skip to content

Commit

Permalink
almost there
Browse files Browse the repository at this point in the history
  • Loading branch information
jcardus committed Feb 16, 2024
1 parent 95957e0 commit c53f1b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "traccar-route-replay",
"version": "1.2.6",
"version": "1.2.7",
"private": true,
"scripts": {
"dev": "nuxt",
Expand All @@ -17,7 +17,7 @@
"@deck.gl/mapbox": "8.9.34",
"@deck.gl/mesh-layers": "8.9.34",
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/i18n": "^7.3.1",
"@nuxtjs/i18n": "7.3.1",
"@turf/bbox": "^6.5.0",
"@turf/bearing": "^6.5.0",
"@turf/circle": "^6.5.0",
Expand Down
30 changes: 21 additions & 9 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<button
class="mapboxgl-ctrl-icon svg-button"
style="background-image: url('backward.svg')"
@click="(i - 1 >= 0) && i--"
@click="clickBackward"
/>
<button
class="mapboxgl-ctrl-icon svg-button"
Expand All @@ -24,7 +24,7 @@
<button
class="mapboxgl-ctrl-icon svg-button"
style="background-image: url('forward.svg')"
@click="(i + 1 < path.length) && i++"
@click="clickForward"
/>
<div class="mapboxgl-ctrl-timeline__label">
<input v-model="from" type="datetime-local">
Expand All @@ -44,9 +44,6 @@
<label for="follow">{{ $t('Follow vehicle') }}</label>
</div>
</div>
<div ref="datetime" class="mapboxgl-ctrl mapboxgl-ctrl-group mapboxgl-ctrl-timeline__label" style="padding: 3px">
{{ timestamps[i] && new Date(timestamps[i]).toLocaleString() }}
</div>
<div ref="speedometer" class="mapboxgl-ctrl">
<speedometer :speed="route[i] && route[i].speed * 1.852" />
</div>
Expand Down Expand Up @@ -152,9 +149,6 @@ export default {
}
},
watch: {
/* currentTime (value) {
this.$refs.noUiSlider.noUiSlider.set([value])
}, */
geofences () {
const features = featureCollection(
this.geofences
Expand All @@ -178,6 +172,9 @@ export default {
map.getSource('route').setData(lineString(this.path.slice(0, this.i)))
}
if (this.path[this.i]) {
if (this.playing) {
this.updateSlider()
}
const model = get3dModel(this.device && this.device.category)
overlay.setProps({
layers: [new ScenegraphLayer({
Expand Down Expand Up @@ -348,7 +345,6 @@ export default {
map.on('style.load', this.styleLoaded)
map.on('styleimagemissing', this.styleImageMissing)
map.addControl({ onAdd: () => this.$refs.slider }, 'top-right')
map.addControl({ onAdd: () => this.$refs.datetime }, 'top-right')
map.addControl({ onAdd: () => this.$refs.speedometer }, 'top-right')
map.addControl(new mapboxgl.NavigationControl())
map.addControl({ onAdd: () => this.$refs.styleSwitcher })
Expand All @@ -366,6 +362,7 @@ export default {
{ to: value => new Date(value).toLocaleString() },
{ to: value => new Date(value).toLocaleString() }
],
step: 1,
pips: {
mode: 'positions',
values: [0, 50, 100],
Expand All @@ -379,6 +376,21 @@ export default {
this.$refs.noUiSlider.noUiSlider.on('update', ([from, to]) => { this.currentTime = to })
},
methods: {
updateSlider () {
this.$refs.noUiSlider.noUiSlider.set([null, this.currentTime])
},
clickBackward () {
if (this.i - 1 >= 0) {
this.i--
this.updateSlider()
}
},
clickForward () {
if (this.i + 1 < this.path.length) {
this.i++
this.updateSlider()
}
},
styleImageMissing (e) {
if (e.id.startsWith('regulatory')) {
const img = new Image(20, 20)
Expand Down

0 comments on commit c53f1b7

Please sign in to comment.