diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap
index 9795528..209f8f2 100644
--- a/src/components/App/__snapshots__/App.test.js.snap
+++ b/src/components/App/__snapshots__/App.test.js.snap
@@ -497,17 +497,17 @@ exports[`App Route / authenticated 1`] = `
North America
@@ -517,7 +517,7 @@ exports[`App Route / authenticated 1`] = `
Europe
@@ -1894,17 +1894,17 @@ exports[`App Route /home authenticated 1`] = `
North America
@@ -1914,7 +1914,7 @@ exports[`App Route /home authenticated 1`] = `
Europe
diff --git a/src/components/VehicleMap/index.jsx b/src/components/VehicleMap/index.jsx
index 1af736a..b0fecd9 100644
--- a/src/components/VehicleMap/index.jsx
+++ b/src/components/VehicleMap/index.jsx
@@ -12,6 +12,7 @@ import { ValidateLocationData } from "../../utils/locations";
import { useUserContext } from "../Contexts/UserContext";
import { useVehicleContext, VehicleProvider } from "../Contexts/VehicleContext";
import { VehiclePopUp } from "./popup";
+import { useLocalStorage } from "../useLocalStorage";
import zoomLocations from './zoomLocations.json';
const Component = () => {
@@ -29,6 +30,7 @@ const Component = () => {
const [zoom, setZoom] = useState(2);
const [markers, setMarkers] = useState([]);
const [connections, setConnections] = useState({});
+ const [lastMapCenter, setLastMapCenter] = useLocalStorage("MAP_CENTER", "");
useEffect(() => {
if (!token) return;
@@ -62,10 +64,16 @@ const Component = () => {
};
const centerAroundMarkers = (points) => {
- let defaultLocationJSON = process.env.REACT_APP_HOME_MAP_DEFAULT_LOCATION;
- let defaultLocation = JSON.parse(defaultLocationJSON)
- setCenter([defaultLocation.lat, defaultLocation.lng]);
- setZoom(defaultLocation.zoom);
+ if (lastMapCenter) {
+ let zoomLocation = JSON.parse(lastMapCenter)
+ setCenter(zoomLocation.center);
+ setZoom(zoomLocation.zoom)
+ } else {
+ let defaultLocationJSON = process.env.REACT_APP_HOME_MAP_DEFAULT_LOCATION;
+ let defaultLocation = JSON.parse(defaultLocationJSON)
+ setCenter([defaultLocation.lat, defaultLocation.lng]);
+ setZoom(defaultLocation.zoom);
+ }
};
useEffect(() => {
@@ -105,6 +113,7 @@ const Component = () => {
};
const focusMap = (e) => {
+ setLastMapCenter(e.target.value)
let zoomLocation = JSON.parse(e.target.value)
setCenter(zoomLocation.center);
setZoom(zoomLocation.zoom)
@@ -145,7 +154,7 @@ const Component = () => {
return (
<>
-
+