Skip to content

Commit b271597

Browse files
authored
Merge pull request #50 from allmaps/develop
Develop
2 parents c4971f9 + 9d55972 commit b271597

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pnpm run dev
3838

3939
Then open [http://localhost:5173](http://localhost:5173).
4040

41+
The Vite dev server allows hosts ending in `.ngrok-free.dev` so the local app can be exposed through an ngrok tunnel for testing on phones and tablets. This is only for local development; production hosts are controlled by the deployed site URL and hosting provider.
42+
4143
### Check And build
4244

4345
```bash

src/lib/components/Map.svelte

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@
183183
let liveLocationInitialFlyToActive = false;
184184
let liveLocationInitialFlyToPending = false;
185185
let previousLiveLocationFollowSequence = 0;
186+
let previousLiveLocationFollowAnnotation: string | undefined;
186187
let isSyncing = false;
187188
let previousLocationSyncCommandId = 0;
188189
let activeLocationSyncCommandId = 0;
@@ -260,13 +261,19 @@
260261
liveLocationInitialFlyToActive = false;
261262
liveLocationInitialFlyToPending = false;
262263
previousLiveLocationFollowSequence = 0;
264+
previousLiveLocationFollowAnnotation = undefined;
263265
}
264266
265267
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;
267271
268272
previousLiveLocationFollowSequence = userLocation.positionSequence;
269-
followLiveUserLocation(userLocation, annotationForZoom);
273+
previousLiveLocationFollowAnnotation = annotationForZoom;
274+
followLiveUserLocation(userLocation, annotationForZoom, {
275+
duration: annotationChanged && !locationChanged ? getCameraCorrectionDuration() : undefined
276+
});
270277
});
271278
272279
// Show saved search and locator points.
@@ -488,7 +495,8 @@
488495
489496
function followLiveUserLocation(
490497
userLocation: LiveUserLocation,
491-
annotationForZoom = activeAnnotation
498+
annotationForZoom = activeAnnotation,
499+
options: { duration?: number } = {}
492500
) {
493501
if (!map) return;
494502
@@ -523,7 +531,7 @@
523531
zoom,
524532
bearing,
525533
pitch: 0,
526-
duration: LIVE_LOCATION_MOVE_DURATION_MS,
534+
duration: options.duration ?? LIVE_LOCATION_MOVE_DURATION_MS,
527535
essential: true
528536
});
529537
}
@@ -1027,10 +1035,14 @@
10271035
zoom: clampZoomToMapLimits(zoom),
10281036
bearing: map.getBearing(),
10291037
pitch: 0,
1030-
duration: config.autoplay?.flyToDurationMs ?? 100
1038+
duration: getCameraCorrectionDuration()
10311039
});
10321040
}
10331041
1042+
function getCameraCorrectionDuration() {
1043+
return config.autoplay?.flyToDurationMs ?? 100;
1044+
}
1045+
10341046
function finishSelectedMapZoomLimit(annotationForLimit: string) {
10351047
if (annotationForLimit !== activeAnnotation) return;
10361048

0 commit comments

Comments
 (0)