Skip to content

Commit

Permalink
Merge pull request #10 from robertd2000/9-overview
Browse files Browse the repository at this point in the history
9 overview
  • Loading branch information
robertd2000 authored Mar 18, 2024
2 parents 5e40459 + 0fa8fb5 commit 434fb31
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 13 deletions.
19 changes: 9 additions & 10 deletions src/components/Map/FlightsLayer/hooks/useFlights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { Feature } from "ol";
import { Point } from "ol/geom";
import { fromLonLat } from "ol/proj";
import { useQuery } from "@tanstack/react-query";
import { getStates } from "@/api/flights/states.api";
// import { getStates } from "@/api/flights/states.api";
import { useMapCoords } from "@/hooks/map/useMapCoords";
import { FlightStates } from "@/types/flights/states.interface";
import { toast } from "sonner";
import { flightData } from "@/mocs/flights";

export const useFlights = () => {
const [flightFeatures, setflightFeatures] = useState<(Feature | null)[]>([]);
Expand All @@ -18,16 +19,14 @@ export const useFlights = () => {
const { error } = useQuery({
queryKey: ["getStates", { lat, lon }],
queryFn: async () => {
const data = await getStates({
lamax,
lamin,
lomax,
lomin,
});
// const data = await getStates({
// lamax,
// lamin,
// lomax,
// lomin,
// });

console.log("data", data);

// const data = flightData;
const data = flightData;

if (data && data?.states?.length) {
setflightFeatures(
Expand Down
7 changes: 4 additions & 3 deletions src/components/Map/FlightsLayer/hooks/useSingleFlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { useQuery } from "@tanstack/react-query";
import { RMap } from "rlayers";
import { Polygon } from "ol/geom";
import { fromLonLat } from "ol/proj";
import { getStateByIcao } from "@/api/flights/states.api";
// import { getStateByIcao } from "@/api/flights/states.api";
import { formatDateFromNow } from "@/utils/date";
import { FlightData, FlightStates } from "@/types/flights/states.interface";
import { toast } from "sonner";
import { flightSingleData } from "@/mocs/flights";

export const useSingleFlight = (mapRef: RefObject<RMap>) => {
const [flightData, setflightData] = useState<FlightData | null>(null);
Expand Down Expand Up @@ -41,8 +42,8 @@ export const useSingleFlight = (mapRef: RefObject<RMap>) => {
const { error, isLoading } = useQuery({
queryKey: ["getStateByIcao"],
queryFn: async () => {
// const data = flightSingleData;
const data = await getStateByIcao(icao as string);
const data = flightSingleData;
// const data = await getStateByIcao(icao as string);

if (data && data?.states?.length) {
const [
Expand Down
3 changes: 3 additions & 0 deletions src/components/Map/MainMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FlightsLayer } from "../FlightsLayer";
import { useSelectMap } from "./hooks/useSelectMap";
import { useMapCoords } from "../../../hooks/map/useMapCoords";
import style from "@/styles/maps/mainMap.module.scss";
import { MapOverview } from "../MapOverview";

export const MainMap = memo(() => {
const { view, mapRef, onSetView } = useMapCoords();
Expand All @@ -27,6 +28,8 @@ export const MainMap = memo(() => {
{/* */}
<FlightsLayer mapRef={mapRef} />
{/* */}
<MapOverview />
{/* */}
<RControl.RScaleLine />
<RControl.RZoom />
<RControl.RZoomSlider />
Expand Down
14 changes: 14 additions & 0 deletions src/components/Map/MapOverview/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { RControl, ROSM } from "rlayers";
import style from "@/styles/maps/mapOverview.module.scss";

export const MapOverview = () => {
return (
<RControl.ROverviewMap
// className="ol-overviewmap example-overview"
collapsed={false}
className={"ol-overviewmap " + style.overviewMap}
>
<ROSM />
</RControl.ROverviewMap>
);
};
31 changes: 31 additions & 0 deletions src/styles/maps/mapOverview.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.overviewMap {
bottom: 2.5rem !important;
left: auto !important;
right: 0.5rem !important;
top: auto !important;

.ol-overviewmap-map {
border: none !important;
border-radius: 15px;
width: 300px !important;
margin: 0.1rem;
}

.ol-overviewmap-box {
border: 2px solid blue;
}

&.ol-uncollapsible {
bottom: 0.5rem !important;
left: auto !important;
right: 0.5rem !important;
top: auto !important;
}

&:not(.ol-collapsed) button {
bottom: 0.5rem !important;
left: auto !important;
right: 0.5rem !important;
top: auto !important;
}
}

0 comments on commit 434fb31

Please sign in to comment.