Commit 8ef3c10 1 parent 4a304e1 commit 8ef3c10 Copy full SHA for 8ef3c10
File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
import AbstractParamConfig , {
2
2
STORE_DISPATCHER_ROUTER_PLUGIN ,
3
3
} from '@/router/storeSync/abstractParamConfig.class'
4
+ import coordinateFromString from '@/utils/coordinates/coordinateExtractors'
4
5
import { removeQueryParamFromHref } from '@/utils/searchParamUtils'
5
6
6
7
export const URL_PARAM_NAME_SWISSSEARCH = 'swisssearch'
@@ -15,9 +16,15 @@ export const URL_PARAM_NAME_SWISSSEARCH = 'swisssearch'
15
16
function dispatchSearchFromUrl ( to , store , urlParamValue ) {
16
17
// avoiding dispatching the search query to the store when there is nothing to set. Not avoiding this makes the CI test very flaky
17
18
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
+ }
18
25
store . dispatch ( 'setSearchQuery' , {
19
26
query : urlParamValue ,
20
- shouldCenter : ! ( to . query . crosshair && to . query . center ) ,
27
+ shouldCenter : shouldCenter ,
21
28
dispatcher : STORE_DISPATCHER_ROUTER_PLUGIN ,
22
29
originUrlParam : true ,
23
30
} )
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ const actions = {
98
98
// there are situations where we don't want to center on the features or coordinates searched.
99
99
// for example: when we are sharing a position with a search query. In those situation, the
100
100
// 'zoom to extent' should be avoided. We center by default.
101
- if ( extractedCoordinate && shouldCenter ) {
101
+ if ( extractedCoordinate && shouldCenter ) {
102
102
let coordinates = [ ...extractedCoordinate . coordinate ]
103
103
if ( extractedCoordinate . coordinateSystem !== currentProjection ) {
104
104
// special case for LV03 input, we can't use proj4 to transform them into
You can’t perform that action at this time.
0 commit comments