mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Support terrain zones on the new map.
https://github.com/dcs-liberation/dcs_liberation/issues/2039
This commit is contained in:
parent
8c63274f57
commit
cf3ef5b403
@ -8,6 +8,7 @@ import FlightPlansLayer from "../flightplanslayer";
|
||||
import FrontLinesLayer from "../frontlineslayer";
|
||||
import NavMeshLayer from "../navmesh/NavMeshLayer";
|
||||
import SupplyRoutesLayer from "../supplyrouteslayer";
|
||||
import TerrainZonesLayers from "../terrainzones/TerrainZonesLayers";
|
||||
import TgosLayer from "../tgoslayer/TgosLayer";
|
||||
import { CoalitionThreatZones } from "../threatzones";
|
||||
import "./LiberationMap.css";
|
||||
@ -94,6 +95,7 @@ export default function LiberationMap() {
|
||||
<LayersControl.Overlay name="Red navmesh">
|
||||
<NavMeshLayer blue={false} />
|
||||
</LayersControl.Overlay>
|
||||
<TerrainZonesLayers />
|
||||
</LayersControl>
|
||||
</MapContainer>
|
||||
);
|
||||
|
||||
71
client/src/components/terrainzones/TerrainZonesLayers.tsx
Normal file
71
client/src/components/terrainzones/TerrainZonesLayers.tsx
Normal file
@ -0,0 +1,71 @@
|
||||
import { useGetTerrainZonesQuery } from "../../api/liberationApi";
|
||||
import { LatLngLiteral } from "leaflet";
|
||||
import { LayerGroup, LayersControl, Polygon } from "react-leaflet";
|
||||
|
||||
interface TerrainZoneLayerProps {
|
||||
zones: LatLngLiteral[][];
|
||||
color: string;
|
||||
fillColor: string;
|
||||
}
|
||||
|
||||
function TerrainZoneLayer(props: TerrainZoneLayerProps) {
|
||||
return (
|
||||
<LayerGroup>
|
||||
{props.zones.map((poly, idx) => {
|
||||
return (
|
||||
<Polygon
|
||||
key={idx}
|
||||
positions={poly}
|
||||
color={props.color}
|
||||
fillColor={props.fillColor}
|
||||
fillOpacity={1}
|
||||
interactive={false}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</LayerGroup>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TerrainZonesLayers() {
|
||||
const { data, error, isLoading } = useGetTerrainZonesQuery();
|
||||
var exclusion = <></>;
|
||||
var inclusion = <></>;
|
||||
var sea = <></>;
|
||||
|
||||
if (error) {
|
||||
console.error("Error while loading terrain zones", error);
|
||||
} else if (isLoading) {
|
||||
} else if (!data) {
|
||||
console.log("Empty response when loading terrain zones");
|
||||
} else {
|
||||
exclusion = (
|
||||
<TerrainZoneLayer
|
||||
zones={data.exclusion}
|
||||
color="#969696"
|
||||
fillColor="#303030"
|
||||
/>
|
||||
);
|
||||
inclusion = (
|
||||
<TerrainZoneLayer
|
||||
zones={data.inclusion}
|
||||
color="#969696"
|
||||
fillColor="#4b4b4b"
|
||||
/>
|
||||
);
|
||||
sea = (
|
||||
<TerrainZoneLayer zones={data.sea} color="#344455" fillColor="#344455" />
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<LayersControl.Overlay name="Inclusion zones">
|
||||
{exclusion}
|
||||
</LayersControl.Overlay>
|
||||
<LayersControl.Overlay name="Exclusion zones">
|
||||
{inclusion}
|
||||
</LayersControl.Overlay>
|
||||
<LayersControl.Overlay name="Sea zones">{sea}</LayersControl.Overlay>
|
||||
</>
|
||||
);
|
||||
}
|
||||
1
client/src/components/terrainzones/index.ts
Normal file
1
client/src/components/terrainzones/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export { default } from "./TerrainZonesLayers";
|
||||
Loading…
x
Reference in New Issue
Block a user