|
1 | 1 | import { IS_TESTING_WITH_CYPRESS } from '@/config'
|
2 | 2 | import i18n from '@/modules/i18n'
|
3 |
| -import { WEBMERCATOR, WGS84 } from '@/utils/coordinates/coordinateSystems' |
| 3 | +import { WGS84 } from '@/utils/coordinates/coordinateSystems' |
4 | 4 | import log from '@/utils/logging'
|
5 | 5 | import proj4 from 'proj4'
|
6 | 6 |
|
7 | 7 | let geolocationWatcher = null
|
8 | 8 | let firstTimeActivatingGeolocation = true
|
9 | 9 |
|
10 |
| -const readPositionEpsg3857 = (position) => { |
| 10 | +const readPosition = (position, projection) => { |
11 | 11 | const { coords } = position
|
12 |
| - return proj4(WGS84.epsg, WEBMERCATOR.epsg, [coords.longitude, coords.latitude]) |
| 12 | + return proj4(WGS84.epsg, projection.epsg, [coords.longitude, coords.latitude]) |
13 | 13 | }
|
14 | 14 |
|
15 | 15 | const handlePositionAndDispatchToStore = (position, store) => {
|
16 |
| - const positionEpsg3857 = readPositionEpsg3857(position) |
17 |
| - store.dispatch('setGeolocationPosition', positionEpsg3857) |
| 16 | + const positionProjected = readPosition(position, store.state.position.projection) |
| 17 | + store.dispatch('setGeolocationPosition', positionProjected) |
18 | 18 | store.dispatch('setGeolocationAccuracy', position.coords.accuracy)
|
19 | 19 | // if tracking is active, we center the view of the map on the position received
|
20 | 20 | if (store.state.geolocation.tracking) {
|
21 |
| - store.dispatch('setCenter', positionEpsg3857) |
| 21 | + store.dispatch('setCenter', positionProjected) |
22 | 22 | }
|
23 | 23 | }
|
24 | 24 |
|
|
0 commit comments