|
183 | 183 | let liveLocationInitialFlyToActive = false; |
184 | 184 | let liveLocationInitialFlyToPending = false; |
185 | 185 | let previousLiveLocationFollowSequence = 0; |
| 186 | + let previousLiveLocationFollowAnnotation: string | undefined; |
186 | 187 | let isSyncing = false; |
187 | 188 | let previousLocationSyncCommandId = 0; |
188 | 189 | let activeLocationSyncCommandId = 0; |
|
260 | 261 | liveLocationInitialFlyToActive = false; |
261 | 262 | liveLocationInitialFlyToPending = false; |
262 | 263 | previousLiveLocationFollowSequence = 0; |
| 264 | + previousLiveLocationFollowAnnotation = undefined; |
263 | 265 | } |
264 | 266 |
|
265 | 267 | if (!enableFlyTo || !mapReady || !map || trackingStatus !== 'active' || !userLocation) return; |
266 | | - if (userLocation.positionSequence === previousLiveLocationFollowSequence) return; |
| 268 | + const locationChanged = userLocation.positionSequence !== previousLiveLocationFollowSequence; |
| 269 | + const annotationChanged = annotationForZoom !== previousLiveLocationFollowAnnotation; |
| 270 | + if (!locationChanged && !annotationChanged) return; |
267 | 271 |
|
268 | 272 | previousLiveLocationFollowSequence = userLocation.positionSequence; |
269 | | - followLiveUserLocation(userLocation, annotationForZoom); |
| 273 | + previousLiveLocationFollowAnnotation = annotationForZoom; |
| 274 | + followLiveUserLocation(userLocation, annotationForZoom, { |
| 275 | + duration: annotationChanged && !locationChanged ? getCameraCorrectionDuration() : undefined |
| 276 | + }); |
270 | 277 | }); |
271 | 278 |
|
272 | 279 | // Show saved search and locator points. |
|
488 | 495 |
|
489 | 496 | function followLiveUserLocation( |
490 | 497 | userLocation: LiveUserLocation, |
491 | | - annotationForZoom = activeAnnotation |
| 498 | + annotationForZoom = activeAnnotation, |
| 499 | + options: { duration?: number } = {} |
492 | 500 | ) { |
493 | 501 | if (!map) return; |
494 | 502 |
|
|
523 | 531 | zoom, |
524 | 532 | bearing, |
525 | 533 | pitch: 0, |
526 | | - duration: LIVE_LOCATION_MOVE_DURATION_MS, |
| 534 | + duration: options.duration ?? LIVE_LOCATION_MOVE_DURATION_MS, |
527 | 535 | essential: true |
528 | 536 | }); |
529 | 537 | } |
|
1027 | 1035 | zoom: clampZoomToMapLimits(zoom), |
1028 | 1036 | bearing: map.getBearing(), |
1029 | 1037 | pitch: 0, |
1030 | | - duration: config.autoplay?.flyToDurationMs ?? 100 |
| 1038 | + duration: getCameraCorrectionDuration() |
1031 | 1039 | }); |
1032 | 1040 | } |
1033 | 1041 |
|
| 1042 | + function getCameraCorrectionDuration() { |
| 1043 | + return config.autoplay?.flyToDurationMs ?? 100; |
| 1044 | + } |
| 1045 | +
|
1034 | 1046 | function finishSelectedMapZoomLimit(annotationForLimit: string) { |
1035 | 1047 | if (annotationForLimit !== activeAnnotation) return; |
1036 | 1048 |
|
|
0 commit comments