Add a basic React implementation of the map.

See client/README.md for instructions.
This commit is contained in:
Dan Albert
2022-02-26 14:15:39 -08:00
parent 4e348dd99a
commit 59e98b31df
32 changed files with 30095 additions and 12 deletions

35
client/src/App.tsx Normal file
View File

@@ -0,0 +1,35 @@
import { LatLng } from "leaflet";
import "./App.css";
import { LiberationMap } from "./map/liberationmap/LiberationMap";
import { ControlPoint } from "./game/controlpoint";
import { useEffect } from "react";
import { useAppDispatch } from "./app/hooks";
import { setControlPoints } from "./game/theater/theaterSlice";
import axios from "axios";
function App() {
const mapCenter: LatLng = new LatLng(25.58, 54.9);
const dispatch = useAppDispatch();
useEffect(() => {
axios
.get("http://[::1]:5000/control-points")
.catch((error) => console.log(`Error fetching control points: ${error}`))
.then((response) => {
if (response != null) {
dispatch(setControlPoints(response.data as ControlPoint[]));
}
});
});
console.log(`mapCenter=${mapCenter}`);
return (
<div className="App">
<LiberationMap mapCenter={mapCenter} />
</div>
);
}
export default App;