mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
This is now feature complete with the exception of the ruler, none of which seem to work with react. Someone that understands JS packaging better than I do (which is a very low bar) will need to have a look. https://github.com/dcs-liberation/dcs_liberation/issues/2039
74 lines
1.5 KiB
TypeScript
74 lines
1.5 KiB
TypeScript
import { useGetDebugIpZonesQuery } from "../../api/liberationApi";
|
|
import { LayerGroup, Polygon } from "react-leaflet";
|
|
|
|
interface IpZonesProps {
|
|
flightId: string;
|
|
}
|
|
|
|
function IpZones(props: IpZonesProps) {
|
|
const { data, error, isLoading } = useGetDebugIpZonesQuery({
|
|
flightId: props.flightId,
|
|
});
|
|
|
|
if (isLoading) {
|
|
return <></>;
|
|
}
|
|
|
|
if (error) {
|
|
console.error("Error while loading waypoint IP zone info", error);
|
|
return <></>;
|
|
}
|
|
|
|
if (!data) {
|
|
console.log("Waypoint IP zone returned empty response");
|
|
return <></>;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Polygon
|
|
positions={data.homeBubble}
|
|
color="#ffff00"
|
|
fillOpacity={0.1}
|
|
interactive={false}
|
|
/>
|
|
<Polygon
|
|
positions={data.ipBubble}
|
|
color="#bb89ff"
|
|
fillOpacity={0.1}
|
|
interactive={false}
|
|
/>
|
|
<Polygon
|
|
positions={data.permissibleZone}
|
|
color="#ffffff"
|
|
fillOpacity={0.1}
|
|
interactive={false}
|
|
/>
|
|
|
|
{data.safeZones.map((zone, idx) => {
|
|
return (
|
|
<Polygon
|
|
key={idx}
|
|
positions={zone}
|
|
color="#80BA80"
|
|
fillOpacity={0.1}
|
|
interactive={false}
|
|
/>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
}
|
|
|
|
interface IpZonesLayerProps {
|
|
flightId: string | null;
|
|
}
|
|
|
|
export function IpZonesLayer(props: IpZonesLayerProps) {
|
|
return (
|
|
<LayerGroup>
|
|
{props.flightId ? <IpZones flightId={props.flightId} /> : <></>}
|
|
</LayerGroup>
|
|
);
|
|
}
|