Skip to content

Commit

Permalink
set OpenStreetMap as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Rybeusz100 committed Dec 30, 2023
1 parent 6fce1a3 commit 3a63d8b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions front/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import GoogleMap from './map/googleMap';
import loadGoogleMaps from './map/googleMapsLoader';
import { management } from './lib/utils';
import checkRelease from './lib/checkRelease';
import { VERSION } from './lib/constants';
import { LOCAL_STORAGE_MODE_KEY, VERSION } from './lib/constants';
import type BaseMap from './map/baseMap';
import { ManagementCommand, Mode } from './lib/enums';
import 'ol/ol.css';
Expand Down Expand Up @@ -81,7 +81,7 @@ function changeMode() {
showAirportsBtn.innerText = 'Show airports';
map?.removeMap();
mode = mode === Mode.GoogleMaps ? Mode.OpenStreetMap : Mode.GoogleMaps;
localStorage.setItem('mode', mode.toString());
localStorage.setItem(LOCAL_STORAGE_MODE_KEY, mode.toString());
startApp(mode);
}

Expand Down
1 change: 1 addition & 0 deletions front/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { IColorAlt } from './interfaces';

export const API_URL = import.meta.env.MODE === 'development' ? 'http://localhost:8054' : '.';
export const VERSION = 'v2.1.0';
export const LOCAL_STORAGE_MODE_KEY = 'MapMode';

export const colorAltMap: IColorAlt[] = [
{ color: 0xffffff, alt: 328 }, // 100 meters
Expand Down
17 changes: 10 additions & 7 deletions front/src/lib/storage.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { Mode } from './enums';
import { LOCAL_STORAGE_MODE_KEY } from './constants';
import { Mode } from './enums';

export function getMode() {
let mode: Mode = parseInt(localStorage.getItem('mode') || '0');

if (isNaN(mode) || mode < 0 || mode > 1) {
mode = 0;
export function getMode(): Mode {
const modeFromStorage = localStorage.getItem(LOCAL_STORAGE_MODE_KEY);
if (modeFromStorage) {
const mode = parseInt(modeFromStorage);
if (Object.values(Mode).includes(mode)) {
return mode;
}
}

return mode;
return Mode.OpenStreetMap;
}

0 comments on commit 3a63d8b

Please sign in to comment.