Skip to content

Commit

Permalink
Remember last location
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoff97 committed Oct 2, 2024
1 parent 4dc4cb5 commit 912b178
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions backend-rust/src/height_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ pub fn location_supported(latitude: f32, longitude: f32) -> bool {

let file_name = get_file_name(lat_i, lon_i);

println!("Trying to get file {file_name}");

return File::open(file_name).is_ok();
}

Expand Down
10 changes: 9 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ function SearchComponent({ setImageState, settings, setSettings, grid, setGrid,
async click(e) {
await doSearchFromLocation(setImageState, setGrid, setSettings, e.latlng, settings, pathAndNode, map);
},
moveend(e) {
const center = map.getCenter();
window.localStorage.setItem("lastLocationLat", center.lat.toString());
window.localStorage.setItem("lastLocationLon", center.lng.toString());
}
});
const urlParams = new URLSearchParams(window.location.search);

Expand Down Expand Up @@ -732,6 +737,9 @@ function App() {
};
const [isInfoOpen, setIsisInfoOpen] = useState<boolean>(false);

const lastLocationLat = +(window.localStorage.getItem("lastLocationLat") || "47.42280178926773");
const lastLocationLon = +(window.localStorage.getItem("lastLocationLon") || "10.984954833984375");

return (
<div className="App">
<OverlaysProvider>
Expand All @@ -752,7 +760,7 @@ function App() {
setImageState={setImageState}
pathAndNode={pathAndNode}
setIsInfoOpen={setIsisInfoOpen}></SettingsCard>
<MapContainer center={[47.42280178926773, 10.984954833984375]} zoom={13} scrollWheelZoom={true}>
<MapContainer center={[lastLocationLat, lastLocationLon]} zoom={13} scrollWheelZoom={true}>
<LayersControl position="bottomright">
<LayersControl.BaseLayer checked name="OpenTopoMap">
<TileLayer
Expand Down

0 comments on commit 912b178

Please sign in to comment.