Skip to content

Commit 8ef3c10

Browse files
committed
PB-1480: always set shouldCenter to true when the string is a valid coordinated.
1 parent 4a304e1 commit 8ef3c10

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/mapviewer/src/router/storeSync/SearchParamConfig.class.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import AbstractParamConfig, {
22
STORE_DISPATCHER_ROUTER_PLUGIN,
33
} from '@/router/storeSync/abstractParamConfig.class'
4+
import coordinateFromString from '@/utils/coordinates/coordinateExtractors'
45
import { removeQueryParamFromHref } from '@/utils/searchParamUtils'
56

67
export const URL_PARAM_NAME_SWISSSEARCH = 'swisssearch'
@@ -15,9 +16,15 @@ export const URL_PARAM_NAME_SWISSSEARCH = 'swisssearch'
1516
function dispatchSearchFromUrl(to, store, urlParamValue) {
1617
// avoiding dispatching the search query to the store when there is nothing to set. Not avoiding this makes the CI test very flaky
1718
if (urlParamValue) {
19+
let shouldCenter = !(to.query.crosshair && to.query.center)
20+
// When the query is a valid coordinate, we want to center the map
21+
const extractedCoordinate = coordinateFromString(to.query[URL_PARAM_NAME_SWISSSEARCH])
22+
if (extractedCoordinate) {
23+
shouldCenter = true
24+
}
1825
store.dispatch('setSearchQuery', {
1926
query: urlParamValue,
20-
shouldCenter: !(to.query.crosshair && to.query.center),
27+
shouldCenter: shouldCenter,
2128
dispatcher: STORE_DISPATCHER_ROUTER_PLUGIN,
2229
originUrlParam: true,
2330
})

packages/mapviewer/src/store/modules/search.store.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const actions = {
9898
// there are situations where we don't want to center on the features or coordinates searched.
9999
// for example: when we are sharing a position with a search query. In those situation, the
100100
// 'zoom to extent' should be avoided. We center by default.
101-
if (extractedCoordinate && shouldCenter) {
101+
if (extractedCoordinate && shouldCenter) {
102102
let coordinates = [...extractedCoordinate.coordinate]
103103
if (extractedCoordinate.coordinateSystem !== currentProjection) {
104104
// special case for LV03 input, we can't use proj4 to transform them into

0 commit comments

Comments
 (0)