|
1 | 1 | import search, { CombinedSearchResults, RESULT_TYPE } from '@/api/search.api'
|
2 | 2 | import { isWhat3WordsString, retrieveWhat3WordsLocation } from '@/api/what3words.api'
|
3 | 3 | import coordinateFromString from '@/utils/coordinates/coordinateExtractors'
|
| 4 | +import CustomCoordinateSystem from '@/utils/coordinates/CustomCoordinateSystem.class' |
4 | 5 | import { STANDARD_ZOOM_LEVEL_1_25000_MAP } from '@/utils/coordinates/SwissCoordinateSystem.class'
|
5 | 6 | import { ActiveLayerConfig } from '@/utils/layerUtils'
|
6 | 7 | import log from '@/utils/logging'
|
@@ -49,22 +50,41 @@ const actions = {
|
49 | 50 | let updatedSearchResults = false
|
50 | 51 | // only firing search if query is longer than 2 chars
|
51 | 52 | if (query.length > 2) {
|
| 53 | + const currentProjection = rootState.position.projection |
52 | 54 | // checking first if this corresponds to a set of coordinates (or a what3words)
|
53 |
| - const coordinate = coordinateFromString(query) |
| 55 | + const coordinate = coordinateFromString(query, currentProjection) |
54 | 56 | if (coordinate) {
|
55 | 57 | dispatch('setCenter', coordinate)
|
56 |
| - dispatch('setZoom', STANDARD_ZOOM_LEVEL_1_25000_MAP) |
| 58 | + if (currentProjection instanceof CustomCoordinateSystem) { |
| 59 | + dispatch( |
| 60 | + 'setZoom', |
| 61 | + currentProjection.transformStandardZoomLevelToCustom( |
| 62 | + STANDARD_ZOOM_LEVEL_1_25000_MAP |
| 63 | + ) |
| 64 | + ) |
| 65 | + } else { |
| 66 | + dispatch('setZoom', STANDARD_ZOOM_LEVEL_1_25000_MAP) |
| 67 | + } |
57 | 68 | dispatch('setPinnedLocation', coordinate)
|
58 | 69 | } else if (isWhat3WordsString(query)) {
|
59 |
| - retrieveWhat3WordsLocation(query).then((what3wordLocation) => { |
| 70 | + retrieveWhat3WordsLocation(query, currentProjection).then((what3wordLocation) => { |
60 | 71 | dispatch('setCenter', what3wordLocation)
|
61 |
| - dispatch('setZoom', STANDARD_ZOOM_LEVEL_1_25000_MAP) |
| 72 | + if (currentProjection instanceof CustomCoordinateSystem) { |
| 73 | + dispatch( |
| 74 | + 'setZoom', |
| 75 | + currentProjection.transformStandardZoomLevelToCustom( |
| 76 | + STANDARD_ZOOM_LEVEL_1_25000_MAP |
| 77 | + ) |
| 78 | + ) |
| 79 | + } else { |
| 80 | + dispatch('setZoom', STANDARD_ZOOM_LEVEL_1_25000_MAP) |
| 81 | + } |
62 | 82 | dispatch('setPinnedLocation', what3wordLocation)
|
63 | 83 | })
|
64 | 84 | } else {
|
65 | 85 | try {
|
66 | 86 | const searchResults = await search(
|
67 |
| - rootState.position.projection, |
| 87 | + currentProjection, |
68 | 88 | query,
|
69 | 89 | rootState.i18n.lang
|
70 | 90 | )
|
|
0 commit comments