29
29
<div class =" mapboxgl-ctrl-timeline__label" >
30
30
<input v-model =" from" type =" datetime-local" >
31
31
</div >
32
- <input
33
- ref =" sliderInput"
34
- v-model =" currentTime"
35
- class =" mapboxgl-ctrl-timeline__slider"
36
- type =" range"
37
- :min =" min"
38
- :max =" max"
39
- :style =" `background-image: url('${sliderBackground}');`"
40
- >
32
+ <div ref =" noUiSlider" class =" mapboxgl-ctrl-timeline__slider" :style =" `background-image: url('${sliderBackground}');`" style =" border : 0 " />
41
33
<div class =" mapboxgl-ctrl-timeline__label" >
42
34
<input v-model =" to" type =" datetime-local" >
43
35
</div >
@@ -82,6 +74,8 @@ import mapboxgl from 'mapbox-gl'
82
74
import { Viewer } from ' mapillary-js'
83
75
import { parse } from ' wellknown'
84
76
import flip from ' @turf/flip'
77
+ import * as noUiSlider from ' nouislider'
78
+ import ' nouislider/dist/nouislider.css'
85
79
import { closest , green } from ' @/utils'
86
80
import StyleSwitcher from ' @/components/style-switcher.vue'
87
81
import { getImage , init } from ' @/utils/mapillary'
@@ -158,6 +152,9 @@ export default {
158
152
}
159
153
},
160
154
watch: {
155
+ /* currentTime (value) {
156
+ this.$refs.noUiSlider.noUiSlider.set([value])
157
+ }, */
161
158
geofences () {
162
159
const features = featureCollection (
163
160
this .geofences
@@ -180,8 +177,8 @@ export default {
180
177
if (this .i > 1 && map .getSource (' route' )) {
181
178
map .getSource (' route' ).setData (lineString (this .path .slice (0 , this .i )))
182
179
}
183
- if (this .model ) {
184
- const model = get3dModel (this .device .category )
180
+ if (this .path [ this . i ] ) {
181
+ const model = get3dModel (this .device && this . device .category )
185
182
overlay .setProps ({
186
183
layers: [new ScenegraphLayer ({
187
184
id: model,
@@ -199,24 +196,17 @@ export default {
199
196
sizeMinPixels: model .sizeMinPixels || 12
200
197
})]
201
198
})
199
+ if (this .follow ) {
200
+ const camera = map .getFreeCameraOptions ()
201
+ camera .position = mapboxgl .MercatorCoordinate .fromLngLat (
202
+ [this .route [this .i ].longitude , this .route [this .i ].latitude - (maxLatitudeDistance / this .playSpeed )],
203
+ this .cameraAltitude
204
+ )
205
+ camera .lookAtPoint (this .path [this .i ])
206
+ map .setFreeCameraOptions (camera)
207
+ }
208
+ this .checkImage ()
202
209
}
203
- if (this .follow ) {
204
- const camera = map .getFreeCameraOptions ()
205
- camera .position = mapboxgl .MercatorCoordinate .fromLngLat (
206
- [this .route [this .i ].longitude , this .route [this .i ].latitude - (maxLatitudeDistance / this .playSpeed )],
207
- this .cameraAltitude
208
- )
209
- camera .lookAtPoint (this .path [this .i ])
210
- map .setFreeCameraOptions (camera)
211
- }
212
- if (this .cockpit ) {
213
- const camera = map .getFreeCameraOptions ()
214
- camera .position = mapboxgl .MercatorCoordinate .fromLngLat (
215
- [this .route [this .i ].longitude , this .route [this .i ].latitude ])
216
- camera .setPitchBearing (180 , this .route [this .i ].course )
217
- map .setFreeCameraOptions (camera)
218
- }
219
- this .checkImage ()
220
210
},
221
211
path () {
222
212
this .loading = false
@@ -227,6 +217,13 @@ export default {
227
217
this .updateSliderBackground ()
228
218
init (bounds, this .path , map)
229
219
this .checkImage ()
220
+ this .$refs .noUiSlider .noUiSlider .updateOptions ({
221
+ range: {
222
+ min: this .min ,
223
+ max: this .max
224
+ }
225
+ })
226
+ this .$refs .noUiSlider .noUiSlider .set ([this .min , this .max ])
230
227
}
231
228
},
232
229
playing () {
@@ -336,7 +333,7 @@ export default {
336
333
}
337
334
},
338
335
mounted () {
339
- new ResizeObserver (this .updateSliderBackground ).observe (this .$refs .sliderInput )
336
+ new ResizeObserver (this .updateSliderBackground ).observe (this .$refs .noUiSlider )
340
337
this .loading = true
341
338
map = new mapboxgl.Map ({
342
339
container: ' map' , // container ID
@@ -361,6 +358,25 @@ export default {
361
358
accessToken: process .env .MAPILLARY_ACCESS_TOKEN ,
362
359
container: this .$refs .mapillaryViewer
363
360
})
361
+ noUiSlider .create (this .$refs .noUiSlider ,
362
+ {
363
+ start: [this .min , this .max ],
364
+ connect: true ,
365
+ tooltips: [
366
+ { to : value => new Date (value).toLocaleString () },
367
+ { to : value => new Date (value).toLocaleString () }
368
+ ],
369
+ pips: {
370
+ mode: ' positions' ,
371
+ values: [0 , 50 , 100 ],
372
+ format: { to : value => new Date (value).toLocaleString () }
373
+ },
374
+ range: {
375
+ min: this .min || 0 ,
376
+ max: this .max || 0
377
+ }
378
+ })
379
+ this .$refs .noUiSlider .noUiSlider .on (' update' , ([from , to ]) => { this .currentTime = to })
364
380
},
365
381
methods: {
366
382
styleImageMissing (e ) {
@@ -372,14 +388,20 @@ export default {
372
388
},
373
389
checkImage () {
374
390
const i = this .i
375
- const image = getImage (this .path [i], this .route [i].course )
376
- if (image .id && this .imgId !== image .id && this .imgTime !== ' loading...' ) {
377
- this .imgTime = ' loading...'
378
- this .imgId = image .id
379
- viewer .moveTo (image .id )
380
- .then (() => { this .imgTime = new Date (this .route [i].fixTime ).toLocaleString () })
381
- .catch ((e ) => { this .imgTime = e .message })
382
- // viewer.setCenter(this.route[this.i].course)
391
+ if (this .route [i]) {
392
+ const image = getImage (this .path [i], this .route [i].course )
393
+ if (image .id && this .imgId !== image .id && this .imgTime !== ' loading...' ) {
394
+ this .imgTime = ' loading...'
395
+ this .imgId = image .id
396
+ viewer .moveTo (image .id )
397
+ .then (() => {
398
+ this .imgTime = new Date (this .route [i].fixTime ).toLocaleString ()
399
+ })
400
+ .catch ((e ) => {
401
+ this .imgTime = e .message
402
+ })
403
+ // viewer.setCenter(this.route[this.i].course)
404
+ }
383
405
}
384
406
},
385
407
styleChanged (style ) {
@@ -408,7 +430,7 @@ export default {
408
430
status = 0
409
431
}
410
432
})
411
- this .drawLine (context, linePosition, this .$refs .sliderInput .clientWidth , - 1 )
433
+ this .drawLine (context, linePosition, this .$refs .noUiSlider .clientWidth , - 1 )
412
434
this .sliderBackground = canvas .toDataURL ()
413
435
}
414
436
},
@@ -420,13 +442,13 @@ export default {
420
442
1 : green,
421
443
2 : ' #F9B218'
422
444
}[status]
423
- context .lineWidth = 10
424
- context .moveTo (start, 4 )
425
- context .lineTo (end, 4 )
445
+ context .lineWidth = 20
446
+ context .moveTo (start, 10 )
447
+ context .lineTo (end, 10 )
426
448
context .stroke ()
427
449
},
428
450
getEndIndex (date ) {
429
- return this .$refs .sliderInput .clientWidth * (new Date (date) - this .min ) / (this .max - this .min )
451
+ return this .$refs .noUiSlider .clientWidth * (new Date (date) - this .min ) / (this .max - this .min )
430
452
},
431
453
newColoredLine (p , context , currentLinePosition , currentStatus ) {
432
454
const end = this .getEndIndex (p .fixTime )
@@ -548,4 +570,14 @@ export default {
548
570
height : 32px !important ;
549
571
background-color : red ;
550
572
}
573
+ .noUi-horizontal .noUi-tooltip {bottom : -150% ;}
574
+ .noUi-connect {
575
+ background : rgba (0 ,0 ,0 ,0.4 );
576
+ }
577
+ .noUi-pips {
578
+ position : absolute ;
579
+ color : #999 ;
580
+ text-shadow : -1px -1px 0 #fff , 1px -1px 0 #fff , -1px 1px 0 #fff , 1px 1px 0 #fff ;
581
+
582
+ }
551
583
</style >
0 commit comments