Skip to content

Commit 4716db2

Browse files
committed
PB-2064: Fix failed to parse crosshair.
1 parent 40fc0b7 commit 4716db2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export default function setCrossHair(
1717
if (!crossHair) {
1818
this.crossHair = undefined
1919
this.crossHairPosition = undefined
20-
} else if (crossHair in CrossHairs) {
20+
} else if (Object.values(CrossHairs).includes(crossHair)) {
21+
// Use Object.values().includes() to check if the crosshair is a valid enum value
22+
// (e.g., 'point', 'cross', etc.) rather than checking if it's an enum key
2123
this.crossHair = crossHair
2224
// if a position is defined as param we use it
2325
// if no position was given, we use the current center of the map as crosshair position

packages/viewer/src/store/plugins/storeSync/params/crosshair.param.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ function setValuesInStore(to: RouteLocationNormalizedGeneric, urlParamValue?: st
5757
},
5858
STORE_DISPATCHER_ROUTER_PLUGIN
5959
)
60+
} else if (parsedValue.crossHair) {
61+
// Handle case where only crosshair type is provided (without coordinates)
62+
// The setCrossHair action will use the map center as the crosshair position
63+
positionStore.setCrossHair(
64+
{
65+
crossHair: parsedValue.crossHair,
66+
},
67+
STORE_DISPATCHER_ROUTER_PLUGIN
68+
)
6069
}
6170
}
6271
}

0 commit comments

Comments
 (0)