Skip to content

Commit 2019297

Browse files
committed
front: map: add switch button for smooth-travel on map
- add smoothTravel selector and updateSmoothTravel dispatch function - add smoothTravel FormatSwitch in MapSettingsBackgroundSwitches.tsx - add smoothTravel in condition to enable flyTo() in MapSearch.tsx - add translations in map-settings.json (en/fr)
1 parent 48184c6 commit 2019297

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

front/public/locales/en/map-settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"noSpeedLimitByTag": "No composition code",
1717
"operationalpoints": "Operational points",
18-
"platforms":"Platforms",
18+
"platforms": "Platforms",
1919
"routes": "Train blocks",
2020
"signals": "Signals",
2121
"signalingtype": "Signalling block type",
@@ -25,6 +25,7 @@
2525
"showIGNCadastre": "Cadastre ©IGN",
2626
"showOSM": "Map background OSM",
2727
"showOSMtracksections": "OSM tracks",
28+
"smoothTravel": "Smooth travel",
2829
"sncf_psl": "Permanent speed limits",
2930
"speedlimits": "Speed limits",
3031
"stops": "Stop signs",

front/public/locales/fr/map-settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"noSpeedLimitByTag": "Aucun code de composition",
1717
"operationalpoints": "Points remarquables",
18-
"platforms":"Quais",
18+
"platforms": "Quais",
1919
"routes": "Cantons",
2020
"signals": "Signals",
2121
"signalingtype": "Type de block",
@@ -25,6 +25,7 @@
2525
"showIGNCadastre": "Cadastre ©IGN",
2626
"showOSM": "Fond de carte OSM",
2727
"showOSMtracksections": "Voies OSM",
28+
"smoothTravel": "Transition douce",
2829
"sncf_psl": "Limites permanentes de vitesse",
2930
"speedlimits": "Vitesses limites",
3031
"stops": "Pancartes d'arrêt",

front/src/common/Map/Search/MapSearch.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ type MapSearchProps = {
2222

2323
const MapSearch: FC<MapSearchProps> = ({ map, closeMapSearchPopUp }) => {
2424
const dispatch = useDispatch();
25+
const { smoothTravel } = useSelector(getMap);
2526

2627
const updateViewportChange = useCallback(
2728
(value: Partial<Viewport>) => {
28-
if (map) {
29+
if (map && smoothTravel) {
2930
map.flyTo({
3031
center: {
3132
lng: value.longitude || map.getCenter().lng,

front/src/common/Map/Settings/MapSettingsBackgroundSwitches.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
updateShowOSM,
2121
updateShowOSMtracksections,
2222
updateTerrain3DExaggeration,
23+
updateSmoothTravel,
2324
} from 'reducers/map';
2425

2526
const FormatSwitch: FC<{
@@ -47,8 +48,14 @@ const FormatSwitch: FC<{
4748

4849
const MapSettingsBackgroundSwitches: FC<unknown> = () => {
4950
const { t } = useTranslation(['map-settings']);
50-
const { showIGNBDORTHO, showIGNSCAN25, showIGNCadastre, showOSM, showOSMtracksections } =
51-
useSelector(getMap);
51+
const {
52+
showIGNBDORTHO,
53+
showIGNSCAN25,
54+
showIGNCadastre,
55+
showOSM,
56+
showOSMtracksections,
57+
smoothTravel,
58+
} = useSelector(getMap);
5259
const terrain3DExaggeration = useSelector(getTerrain3DExaggeration);
5360
const dispatch = useDispatch();
5461

@@ -111,6 +118,14 @@ const MapSettingsBackgroundSwitches: FC<unknown> = () => {
111118
/>
112119
</div>
113120
</div>
121+
122+
<FormatSwitch
123+
name="smoothTravel-switch"
124+
onChange={() => dispatch(updateSmoothTravel(!smoothTravel))}
125+
state={smoothTravel}
126+
icon=""
127+
label="smoothTravel"
128+
/>
114129
</>
115130
);
116131
};

front/src/reducers/map/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface MapState {
2525
showOSM: boolean;
2626
showOSMtracksections: boolean;
2727
terrain3DExaggeration: number;
28+
smoothTravel: boolean;
2829
viewport: Viewport;
2930
featureInfoClickID?: number;
3031
layersSettings: {
@@ -59,6 +60,7 @@ export const mapInitialState: MapState = {
5960
showOSM: true,
6061
showOSMtracksections: false,
6162
terrain3DExaggeration: 0,
63+
smoothTravel: false,
6264
viewport: {
6365
latitude: 48.32,
6466
longitude: 2.44,
@@ -138,6 +140,9 @@ const mapSlice = createSlice({
138140
) => {
139141
state.terrain3DExaggeration = action.payload;
140142
},
143+
updateSmoothTravel: (state, action: PayloadAction<MapState['smoothTravel']>) => {
144+
state.smoothTravel = action.payload;
145+
},
141146
},
142147
});
143148

@@ -177,6 +182,7 @@ export const {
177182
updateShowOSM,
178183
updateShowOSMtracksections,
179184
updateTerrain3DExaggeration,
185+
updateSmoothTravel,
180186
updateViewportAction,
181187
updateIssuesSettings,
182188
} = mapSliceActions;

front/src/reducers/map/selectors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const getShowIGNCadastre = makeMapStateSelector('showIGNCadastre');
1414
export const getShowOSM = makeMapStateSelector('showOSM');
1515
export const getShowOSMtracksections = makeMapStateSelector('showOSMtracksections');
1616
export const getTerrain3DExaggeration = makeMapStateSelector('terrain3DExaggeration');
17+
export const getSmoothTravel = makeMapStateSelector('smoothTravel');
1718
export const getViewport = makeMapStateSelector('viewport');
1819
export const getLayersSettings = makeMapStateSelector('layersSettings');
1920
export const getMapSearchMarker = makeMapStateSelector('mapSearchMarker');

0 commit comments

Comments
 (0)