diff --git a/src/router/legacyPermalinkManagement.routerPlugin.js b/src/router/legacyPermalinkManagement.routerPlugin.js index c91936e4a..0892fcd8d 100644 --- a/src/router/legacyPermalinkManagement.routerPlugin.js +++ b/src/router/legacyPermalinkManagement.routerPlugin.js @@ -147,18 +147,23 @@ const handleLegacyParam = ( break // if no special work to do, we just copy past legacy params to the new viewer default: + // NOTE: legacyValue is parsed using URLSearchParams which don't make any difference + // between &foo and &foo= newValue = legacyValue break } - if (newValue) { + if (newValue !== undefined) { // When receiving a query, the application will encode the URI components // We decode those so that the new query won't encode encoded character // for example, we avoid having " " becoming %2520 in the URI newQuery[key] = decodeURIComponent(newValue) log.info( - `[Legacy URL] ${param}=${legacyValue} parameter changed to ${key}=${decodeURIComponent(newValue)}` + `[Legacy URL] ${param}=${legacyValue} parameter changed to ${key}=${decodeURIComponent(newValue)}`, + newQuery ) + } else { + log.error(`[Legacy URL] ${param}=${legacyValue} parameter not processed`) } } diff --git a/src/router/storeSync/__tests__/abstractParamConfig.class.spec.js b/src/router/storeSync/__tests__/abstractParamConfig.class.spec.js index be062506c..2537bbd46 100644 --- a/src/router/storeSync/__tests__/abstractParamConfig.class.spec.js +++ b/src/router/storeSync/__tests__/abstractParamConfig.class.spec.js @@ -80,7 +80,7 @@ describe('Test all AbstractParamConfig class functionalities', () => { }) expect(testInstance.readValueFromQuery({ test: 'true' })).to.be.true expect(testInstance.readValueFromQuery({ test: 'false' })).to.be.false - expect(testInstance.readValueFromQuery({ test: '' })).to.be.false + expect(testInstance.readValueFromQuery({ test: '' })).to.be.true // null value means the param without value, we want it to be true expect(testInstance.readValueFromQuery({ test: null })).to.be.true expect(testInstance.readValueFromQuery({})).to.be.undefined @@ -135,7 +135,7 @@ describe('Test all AbstractParamConfig class functionalities', () => { }) expect(testInstance.readValueFromQuery({ test: 'true' })).to.be.true expect(testInstance.readValueFromQuery({ test: 'false' })).to.be.false - expect(testInstance.readValueFromQuery({ test: '' })).to.be.false + expect(testInstance.readValueFromQuery({ test: '' })).to.be.true // null value means the param without value, we want it to be true expect(testInstance.readValueFromQuery({ test: null })).to.be.true expect(testInstance.readValueFromQuery({})).to.be.true diff --git a/src/router/storeSync/abstractParamConfig.class.js b/src/router/storeSync/abstractParamConfig.class.js index 5dc7e4f0d..bd2d6ad38 100644 --- a/src/router/storeSync/abstractParamConfig.class.js +++ b/src/router/storeSync/abstractParamConfig.class.js @@ -79,7 +79,8 @@ export default class AbstractParamConfig { // is present in the query (without a boolean value attached) return ( queryValue === null || - (typeof queryValue === 'string' && queryValue === 'true') || + queryValue === 'true' || + queryValue === '' || (typeof queryValue === 'boolean' && !!queryValue) ) } else if (queryValue === null) { diff --git a/src/store/modules/geolocation.store.js b/src/store/modules/geolocation.store.js index 44bde46c7..fa20e6197 100644 --- a/src/store/modules/geolocation.store.js +++ b/src/store/modules/geolocation.store.js @@ -19,7 +19,7 @@ const state = { * * @type Boolean */ - tracking: false, + tracking: true, /** * Device position in the current application projection [x, y] * diff --git a/src/store/plugins/geolocation-management.plugin.js b/src/store/plugins/geolocation-management.plugin.js index bfb3fcf7c..ae99b96ba 100644 --- a/src/store/plugins/geolocation-management.plugin.js +++ b/src/store/plugins/geolocation-management.plugin.js @@ -55,9 +55,22 @@ const handlePositionAndDispatchToStore = (position, store) => { accuracy: position.coords.accuracy, ...dispatcher, }) - // if tracking is active, we center the view of the map on the position received + // if tracking is active, we center the view of the map on the position received and change + // to the proper zoom if (store.state.geolocation.tracking) { setCenterIfInBounds(store, positionProjected) + // set zoom level if needed + let zoomLevel = STANDARD_ZOOM_LEVEL_1_25000_MAP + if (store.state.position.projection instanceof CustomCoordinateSystem) { + zoomLevel = + store.state.position.projection.transformStandardZoomLevelToCustom(zoomLevel) + } + if (store.state.position.zoom != zoomLevel) { + store.dispatch('setZoom', { + zoom: zoomLevel, + ...dispatcher, + }) + } } } @@ -120,7 +133,7 @@ const handlePositionError = (error, store, state, options = {}) => { } const activeGeolocation = (store, state, options = {}) => { - const { useInitial = false } = options + const { useInitial = true } = options if ( useInitial && store.state.geolocation.position[0] !== 0 && @@ -152,16 +165,6 @@ const activeGeolocation = (store, state, options = {}) => { // handle current position handlePositionAndDispatchToStore(position, store) - - // set zoom level - let zoomLevel = STANDARD_ZOOM_LEVEL_1_25000_MAP - if (state.position.projection instanceof CustomCoordinateSystem) { - zoomLevel = state.position.projection.transformStandardZoomLevelToCustom(zoomLevel) - } - store.dispatch('setZoom', { - zoom: zoomLevel, - ...dispatcher, - }) }, (error) => handlePositionError(error, store, state, { reactivate: true }), {