Skip to content

Commit cf688f4

Browse files
committed
PB-2068: Fix tracking being disabled when geolocation updates position.
- Fix TODO bug in setCenter that disabled tracking when geolocation updated the position - Check dispatcher name to distinguish between geolocation updates and user map movements - Always enable tracking unconditionally after geolocation activation - This fixes the 3-phase bug where tracking would be disabled immediately after activation
1 parent 4488348 commit cf688f4

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

packages/viewer/src/modules/map/components/toolbox/GeolocButton.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ function toggleGeolocation(): void {
5656
// If the geolocation is not active, simply activate it
5757
if (!geolocationStore.active) {
5858
geolocationStore.toggleGeolocation(dispatcher)
59-
// Check if tracking needs to be enabled after activation (old implementation behavior)
60-
if (hasTrackingFeedback.value) {
61-
console.log('[toggleGeolocation] Post-activation: enabling tracking')
62-
geolocationStore.setGeolocationTracking(true, dispatcher)
63-
}
59+
// Always enable tracking after activation (matching old implementation)
60+
console.log('[toggleGeolocation] Post-activation: enabling tracking')
61+
geolocationStore.setGeolocationTracking(true, dispatcher)
6462
} else {
6563
// If the geolocation is active
6664
if (hasTrackingFeedback.value) {

packages/viewer/src/store/modules/position/actions/setCenter.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ export default function setCenter(
4141

4242
const geolocationStore = useGeolocationStore()
4343

44-
// TODO: fix this, it stops the tracking when receiving the first geolocation position update
45-
if (geolocationStore.tracking && geolocationStore.position !== center) {
44+
// Only disable tracking if the center change is NOT from geolocation itself
45+
// This prevents disabling tracking when geolocation updates the position
46+
// Check if the dispatcher is from GeolocButton (which handles all geolocation operations)
47+
const isFromGeolocation = dispatcher.name === 'GeolocButton.vue'
48+
49+
console.log('[setCenter] dispatcher.name:', dispatcher.name, 'tracking:', geolocationStore.tracking, 'position !== center:', geolocationStore.position !== center, 'isFromGeolocation:', isFromGeolocation)
50+
51+
if (geolocationStore.tracking && geolocationStore.position !== center && !isFromGeolocation) {
4652
// if we moved the map we disabled the geolocation tracking (unless the tracking moved the map)
53+
console.log('[setCenter] Disabling tracking because center changed from non-geolocation source')
4754
geolocationStore.setGeolocationTracking(false, dispatcher)
4855
this.setAutoRotation(false, dispatcher)
4956
}

0 commit comments

Comments
 (0)