Draw flight plan paths in the react UI.

https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
Dan Albert
2022-03-01 00:08:34 -08:00
parent bd8aa0296b
commit 406a64ae3f
12 changed files with 183 additions and 18 deletions

View File

@@ -1,12 +1,14 @@
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 { Flight } from "./game/flight";
import { LatLng } from "leaflet";
import { LiberationMap } from "./map/liberationmap/LiberationMap";
import axios from "axios";
import { registerFlight } from "./game/ato/atoSlice";
import { setControlPoints } from "./game/theater/theaterSlice";
import { useAppDispatch } from "./app/hooks";
import { useEffect } from "react";
function App() {
const mapCenter: LatLng = new LatLng(25.58, 54.9);
@@ -22,6 +24,16 @@ function App() {
dispatch(setControlPoints(response.data as ControlPoint[]));
}
});
axios
.get("http://[::1]:5000/flights?with_waypoints=true")
.catch((error) => console.log(`Error fetching flights: ${error}`))
.then((response) => {
if (response != null) {
for (const flight of response.data) {
dispatch(registerFlight(flight as Flight));
}
}
});
});
console.log(`mapCenter=${mapCenter}`);