diff --git a/packages/viewer/src/store/modules/position/actions/setCrossHair.ts b/packages/viewer/src/store/modules/position/actions/setCrossHair.ts index 6012139006..5db37b8f62 100644 --- a/packages/viewer/src/store/modules/position/actions/setCrossHair.ts +++ b/packages/viewer/src/store/modules/position/actions/setCrossHair.ts @@ -17,7 +17,9 @@ export default function setCrossHair( if (!crossHair) { this.crossHair = undefined this.crossHairPosition = undefined - } else if (crossHair in CrossHairs) { + } else if (Object.values(CrossHairs).includes(crossHair)) { + // Use Object.values().includes() to check if the crosshair is a valid enum value + // (e.g., 'point', 'cross', etc.) rather than checking if it's an enum key this.crossHair = crossHair // if a position is defined as param we use it // if no position was given, we use the current center of the map as crosshair position diff --git a/packages/viewer/src/store/plugins/storeSync/params/crosshair.param.ts b/packages/viewer/src/store/plugins/storeSync/params/crosshair.param.ts index a295bbc7cb..0289a24935 100644 --- a/packages/viewer/src/store/plugins/storeSync/params/crosshair.param.ts +++ b/packages/viewer/src/store/plugins/storeSync/params/crosshair.param.ts @@ -57,6 +57,15 @@ function setValuesInStore(to: RouteLocationNormalizedGeneric, urlParamValue?: st }, STORE_DISPATCHER_ROUTER_PLUGIN ) + } else if (parsedValue.crossHair) { + // Handle case where only crosshair type is provided (without coordinates) + // The setCrossHair action will use the map center as the crosshair position + positionStore.setCrossHair( + { + crossHair: parsedValue.crossHair, + }, + STORE_DISPATCHER_ROUTER_PLUGIN + ) } } }